Pass URL to servlet

Hi,
I am new to servlet . I am facing a small issue. I have to pass the url to the servlet. For Example: if user clicks http://myservername:7001/QbpmWeb/servlet/imageServlet?taskInstanceId=304
then in the servlet, i need the myservername and port number. How to get the info?
Thanks in advance
Pankaj

hi :-)
what application server you are using?
if its tomcat, it includes some nice examples in there.
out.println("Request URI: " + request.getRequestURI());will output
/servlets-examples/servlet/RequestInfoExample
to get additional info you can use this
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RequestHeaderExample extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        Enumeration e = request.getHeaderNames();
        while (e.hasMoreElements()) {
            String name = (String)e.nextElement();
            String value = request.getHeader(name);
            out.println(name + " = " + value);
}will output:
accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
referer http://localhost:8080/servlets-examples/
accept-language en-us
accept-encoding gzip, deflate
user-agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
host localhost:8080
connection Keep-Alive
codes and example above are included on tomcat.
if your using tomcat you can check the example by
visiting the url
http://localhost:8080/servlets-examples/
regards,

Similar Messages

  • Null values passed into the servlet

    Hi all,
    I keep getting null values for all the params that I pass into the servlet i.e. sqltype, producttype, process, instance etc....I have attempted to print some of them out on the screen but I keep getting the 'NullPointerException' error message...can anyone tell me what it is that I have down wrong in the below code?
    If I run the servlet with method calls that have hardcoded arguments in them it works but not when I pass in the params from the URL...I am absolutley puzzled!
    Help!
    package blotter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Date;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.db.util.WriteToLogFile;
    import blotter.cache.*;
    Servlet to extract an object that has already been placed
    in the cache by GetBondPrices servlet from the cache.
    public class ExtractSecurityObject extends HttpServlet
         String sqlType = "";
         String productType = "";
         String instance = "";
         String process = "";
         String asOfDate = "";
         String currencyCode = "";
         String curveId = "";
         String results = "";
         private String debug;
    private PrintWriter out;
         private WriteToLogFile logFile;
         // called when servlet first initialised
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         // method called for each get request
         public void doGet( HttpServletRequest request, HttpServletResponse response )
                   throws ServletException, IOException
              String toWrite = " ";
    // Get the object identifier from the parameters passed in
              sqlType = request.getParameter("sqltype");
    productType = request.getParameter("producttype").toUpperCase();
              instance = request.getParameter("instance");
              process = request.getParameter("process");
              asOfDate = request.getParameter("asofdate");
              curveId = request.getParameter("curveid");
              currencyCode = request.getParameter("ccy").toUpperCase();
              out.println(currencyCode);
              if ( request.getParameter("debug") !=null)
                   debug = request.getParameter("debug");
              else
                   debug ="";
              // set the mime type to html
    response.setContentType( "text/html" );
    out = response.getWriter();
    out.println("<HTML>");
              try
              // write some parameters to a log file
              toWrite = toWrite + "<li>" + getServletInfo() + " at " + new Date() + " " + sqlType + " " +
                        productType + " " + instance + " " + process + " " + asOfDate + " " + curveId + " " +
                        currencyCode;
         CachedObject o1 = (CachedObject)CacheManager.getCache("EB_" + currencyCode + productType + asOfDate);
    if(o1 == null){
              CacheSecurityObject cso = new CacheSecurityObject();
                   if((request.getParameter("sqltype") == null) && (request.getParameter("instance") != null)){
    results = (String)cso.putSecurityinCache(null, request.getParameter("producttype"), request.getParameter("instance"), request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    //results = (String)cso.putSecurityinCache(null, "yc", "frafu", "official", "20011105", "baceod", "sek");
    out.println(results);
                   } else {
    //results = (String)cso.putSecurityinCache("bondtypes", "bond", null, "official", "20011105", "baceod", "eur");
    results = (String)cso.putSecurityinCache(request.getParameter("sqltype"), request.getParameter("producttype"), null, request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    out.println(results);
              else{
                   out.println(((String)o1.object).toString());
    // general catch for all exceptions
              catch(Exception exception)
                   out.println( "Exception: The item that you requested was not found in the cache" + "<BR>" );
                   toWrite = toWrite + "Exception : " + exception.getMessage() + "\n" ;
              finally
    // write to logfile
              logFile = new WriteToLogFile();
              logFile.setSourceDirName("blotter");
              logFile.setQuery(request.getQueryString());
              logFile.setServletPath(request.getServletPath());
              if (toWrite!=null)
              logFile.writeLog(getServletInfo(),toWrite);
    out.println("</HTML>");
              out.close();
         // need the class name for log file
         public String getServletInfo()
         return this.getClass().getName();
    }

    That section of the code references a cache to extract an item that has been requested by the user. If the item is not in the cache i.e. if(o1 == null) then it will call a class that generates that object and places that object into the cache. The second time the user makes the same call then they will be handed a cached copy of that object which is aimed to make the whole servlet call faster.
    That section of the code works fine coz I have tested that separately. It is the reading in of the arguments that is causing the problem.

  • Pass data from servlet to jsp using sendRedirect

    Hi,
    I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
    Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
    Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me know

    sendRedirect is meant as a true redirect. meaning
    you can use it to redirect to urls not in your
    context....with forward you couldn't pass information
    to jsps/servlets outside your own context.Actually, you can:
    getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
    Brian

  • Passing Images via servlet

    Hi,
    I need to pass a image from one servlet to another servlet.
    I have tried the RequestDispatcher class, inside that forword method. But it didn't invoke the other servlet.
    Can anybody tell me how to pass the data from one servlet to another servlet?
    Thanks in advance.

    I have tried the RequestDispatcher class, inside that forword method. But it didn't invoke the other servlet.Well then you did it wrong, didn't you? Perhaps you forgot to let the resource start with a "/" ? If your servlet is mapped like this:
    <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
    </servlet-mapping>then your forward needs to be :
    RequestDispatcher rd = request.getRequestDispatcher("/MyServlet");
    rd.forward(request,response);
    return;Before you do the forward you can attach objects to the request like this:
    request.setAttribute("myobject", myobject);And in the servlet you forward to, you can retrieve the object again like this:
    MyObject myobject = (MyObject) request.getAttribute("myobject");

  • BSP Exception: Access to URL /irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher;jsessionid= not allowed

    Dear all,
    I've created out BI system in our new Portal installation and tested the connection. Everything works fine. I added the certificate of the portal to STRUSTSSO2 in BI ABAP and assigned SAP_ALL and SAP_NEW to my Account.in BI. If I open the iView from the portal I get a BSP Exception with the message:
    The used connection by the iView is to the ABAP-Stack of the BI-system not to the JAVA-Stack. Is that correct?
    BSP Exception: Der Zugriff auf die URL /irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher;jsessionid=IDBYatWIpt_pX4uc52ChoZqMWkm1RAFW2qsA_SAP ist untersagt.
    What can be the problem/reason?
    Thanks!

    Hi Gerrit
    In both places you have to provide a authorization access to the end users then only it will work. because your are already said that in SAP_All & SAP_New working fine
    Back end BI system access as per the word document as pasted the link
    https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&cad=rja&uact=8&ved=0CFIQFjAG&url=http%3A%2F%2Fbasisdsp.f…
    For SAP portal you have to create iview's assign the same to end user
    Assigning an Authentication Scheme to an iView - User Authentication and Single Sign-On - SAP Library
    Portal Authentication Infrastructure - Configuring the Portal for Initial Use - SAP Library
    BR
    SS

  • Trouble Passing URL Parameters between Applications

    Hi All,
    I am having trouble Passing URL Parameters between Applications for BW queries as data sources. I know I am getting the data from the sending application correctly, because I an printing to the screen using a Text Component.
    Date From: 1/1/2008
    Date To: 3/14/2014
    Here is the code from the sending application On Select :
    "http://localhost:56572/aad/web.do?APPLICATION=WIMO_SUMMARY_OPEN_DETAIL&designersessionid=37a1cfaa7e734cd9afa35cb4cd627d41" +
    + DS_1.getVariableValueExt("ZPORDAT3") +
    + DS_1.getVariableValueExt("ZPORDAT5"));
    Here is the code from the recieving application Global Script Variable"
    Xv_DateFrom     String     True
    Xv_DateTo         String     True
    Here is the code from the receiving application On Startup"
    DS_2.setFilter("0CALDAY",[Xv_DateFrom, Xv_DateTo]);
    When I click the results of the sending Application the popup window opens for the receiving application but I get all the records for the BW receiving query, it does not restrict to the values in ("ZPORDAT3") 1/1/2008 and ("ZPORDAT5") Date To: 3/14/2014.
    So, I would expect it is my receiving code, but I am not sure.
    Hope you can help?
    Norman

    Hi Norman,
    As Jörg said, please put "&" before each of your variable names at your url. For the second part,I didn't try it for date intervals but keep in mind just in case:
    APPLICATION.openNewWindow("http://localhost:56572/aad/web.do?APPLICATION=WIMO_SUMMARY_OPEN_DETAIL&designersessionid=37a1cfaa7e734cd9afa35cb4cd627d41" +
    "&Xv_DateFrom=" + DS_1.getVariableValueExt("ZPORDAT3") +
    "&Xv_DateTo=" + DS_1.getVariableValueExt("ZPORDAT5"));
    Here is the code from the recieving application Global Script Variable"
    Xv_DateFrom     String     True
    Xv_DateTo         String     True
    Here is the code from the receiving application On Startup"
    DS_2.setFilterExt("0CALDAY", {"low": Xv_DateFrom , "high " : Xv_DateTo});
    Best regards,
    Onur

  • Passing values to servlet

    HI All
    I am developing a project using html and servlets. from my html page(regis.html) i am trying to pass the values which are entered by the user to the servlet (Admin_Regis.java) which is in the another package called Admin. The way i am doing is
    <form class="registerlogin" method="post" action="Adimn/Admin_Regis">
    but i am not able to send the values to the servlet. It showsr HTTP Status 404 - /Adimn/Admin_Regis.
    My question is how to pass the values from html to servlet which is the different packages . I have three more packages .
    Can any body please help me in solving this problem.

    HI
    The problem i was facing ie the values was not able to pass to the servlet i got the part of the solution for that . What actually i have done is i have kept all my web pages in one saperate folder so i was not able to send . But now when all my pages are in default folder even then i was not be send the values can any body please help me out for this problem.

  • FRM-92052 error... unable to connect to server URL /forms/servlet;

    Hi all.
    I'm on forms 11g 11.1.2.1.0
    I'm configuring my form and when I try to run it I have this error:
    FRM-92052: unable to connect to server at URL /forms/servlet;
    I have start up weblogic server and everything is ok.
    When I try to run my form I have the error.
    How can I solve it?
    Thanks all for collaboration,
    Fabrizio

    I open my log file and I copy here error section:
    java.lang.NoSuchMethodError: oracle/forms/net/ConnectionException.<init>(ILjava/lang/String;Ljava/lang/Throwable;)V
         at oracle.forms.servlet.BaseServlet.getConnectionException(Unknown Source)
         at oracle.forms.servlet.BaseServlet.logException(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getRunformSession(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getInfo(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.doGet(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.access$100(Unknown Source)
         at oracle.forms.servlet.ListenerServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    >
    ####<5-feb-2013 14.42.40 CET> <Notice> <Diagnostics> <missuri377> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <2e61ea05cba29510:6243aa29:13caa961585:-8000-0000000000000024> <1360071760720> <BEA-320068> <Watch 'UncheckedException' with severity 'Notice' on server 'AdminServer' has triggered at 5-feb-2013 14.42.40 CET. Notification details:
    WatchRuleType: Log
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
    WatchData: DATE = 5-feb-2013 14.42.40 CET SERVER = AdminServer MESSAGE = [ServletContext@6140131[app:formsapp module:forms path:/forms spec-version:2.5 version:11.1.2]] Root cause of ServletException.
    java.lang.NoSuchMethodError: oracle/forms/net/ConnectionException.<init>(ILjava/lang/String;Ljava/lang/Throwable;)V
         at oracle.forms.servlet.BaseServlet.getConnectionException(Unknown Source)
         at oracle.forms.servlet.BaseServlet.logException(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getRunformSession(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.getInfo(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.doGet(Unknown Source)
         at oracle.forms.servlet.ListenerServlet$Request.access$100(Unknown Source)
         at oracle.forms.servlet.ListenerServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101017 MACHINE = missuri377 TXID = CONTEXTID = 2e61ea05cba29510:6243aa29:13caa961585:-8000-0000000000000022 TIMESTAMP = 1360071760564
    WatchAlarmType: AutomaticReset
    WatchAlarmResetPeriod: 30000
    >
    How can I solve my problem?
    Thanks all for collaboration,
    Fabrizio

  • Passing URL parameters to WD application

    Hi!
    To pass URL parameters to WD application I currenly inbound plug 'defauld' (of type 'Startup') of main window. I use following code:
    types:
        begin of param_t,
          name type string,
          value type string,
        end of param_t.
      data: params type standard table of param_t.
      data: param like line of params.
      wdevent->get_data(
        exporting
          name = '_ALL_URL_PARAMETERS'
        importing
          value = params
    It works fine but this plug is called after init methods of the component controller an of the view. So if I want to do something with parameters, I must do in this plug.
    Is there way to pass URL parameters in a WD app. so that they were available from the very beginning of the application work i.e. in init method of the component controller etc.?
    Thanks!

    I had the same requirement too. There are a couple of threads on the subject as well, I've posted in one of them but had no answer:
    Re: Read URL Parameters programmatically
    The workaround i've used is this, it's definitely not as neat as I would like to since you end up having two initialization methods per controller, WDDOINIT and the one you create (for each controller you want to run code in using the received parameters). Nevertheless, it works:
    1) Create an event in your component controller, for example INIT_COMPLETED.
    2) Define a new method in your component controller, e.g. INIT_AFTER_WINDOW. This method receives an Importing parameter TYPE tihttpnvp. It uses this received HTTP parameters for the initialization logic and finally raises the INIT_COMPLETED event (This is the method that "replaces" WDDOINIT).
    3) In the Window's Inbound plug handler, you get the HTTP parameters (with wdevent->get_data) and afterwards call the method WD_COMP_CONTROLLER->INIT_AFTER_WINDOW (maybe you need to declare the usage previously in the Window to have the reference available).
    4) Finally, if you need some of the Views to be initialized afterwards the component controller's INIT_AFTER_WINDOW runs (for example to show some initialization messages), you'll have to replace the WDDOINIT method with an INIT_AFTER_COMPCTRL method and subscribe it to the component controller's INIT_COMPLETED event.
    I hope you got the idea, and more importantly, that we get some cleaner solution from SAP for achieving this in the future.
    Regards
    Edited by: Alejandro Bindi on Nov 6, 2008 10:08 PM
    INIT_AFTER_WINDOW is the method to be called on step 3

  • No parms passed to controlling servlet

    I want a page with an inputfield, 2 selectboxes and 1 (or more) submit-buttons. User MUST select a button before 'controlling servlet' is executed. (I mean, no action when 'enter' is used).
    These are the 2 scenarios I tried:
    Scenario (A)
    When i put the <Form ...> tag at the top of my jsp and include inputfields and buttons, I get a 500_error when the cursor is in an inputfield and users presses 'enter'.
    It seems that the parameters are not correctly passed to the 'controlling servlet'
    However, when I
    1) 'click' the Submit-button
    or
    2) 'click' outside this inputfield and then 'enter' or 'click' the Submit-button
    the parms are correctly passed and 'controlling servlet' is correctly executed.
    ==>
    <FORM action="/servlet/com.clipper.servlets.FQController" method=POST>
    <td width="150" height="25" colspan="3" bgcolor="#FFFFFF">
         <INPUT size="15" type="text" maxlength="15" tabindex="1" name="agency" value="<%= ((String) session.getValue("sessionid.useragencycode")).trim() %>"></td>
    <td width="600" height="25" bgcolor="#99CCFF" colspan="12">
    <p align="left"><INPUT type=submit tabindex="5" name="action" value=" List "></p></td>
    </FORM>
    Scenario (B)
    I changed code and do not have the 500_error when in inputfield but no parms are passed anymore.
    This is the code
    ==>
    <td width="150" height="25" colspan="3" bgcolor="#FFFFFF">
         <INPUT size="15" type="text" maxlength="15" tabindex="1" name="agency" value="<%= ((String) session.getValue("sessionid.useragencycode")).trim() %>"></td>
    <FORM action="/servlet/com.clipper.servlets.FQController" method=POST>
    <td width="600" height="25" bgcolor="#99CCFF" colspan="12">
    <p align="left"><INPUT type=submit tabindex="5" name="action" value=" List "></p></td></FORM>
    What is the correct implementation of this ?

    1. your text field or any other form fields have to place between the <form> and </form> tag..
    2. I don't know why you didn't get any paramter values, but you can write a function to list all the parameters that were in the request, call the function in the beginning of your control servlet.... Below is a sample...
         public static void listParameterValues(HttpServletRequest request) {
            Enumeration names = request.getParameterNames();
            if(names != null)  {
              String name="";
              while(names.hasMoreElements())  {
                name = (String)names.nextElement();
                String[] values = request.getParameterValues(name);
                if(values != null)  {
                  for(int i=0; i<values.length; i++)  {
                    System.out.println("listParameterValues(), " + name + "[" + i + "] = " + values);

  • Pass URL parameters from BSP to WDA for ABAP (via Post   )

    Dear Gurus,/ Joerge,
    I am unable to post my Code here, but with the guidance provided by Joerge i am able to solve this
    i Have been through the Below thread
    Pass URL parameters from WD to BSP via Post
    Dear Gurus,
    "Since I am unable to Post new thread i am Continuing this thread, though this Issue has been
    " resolved,i need some more info on the following issue, Kindly guide me,
    I have gone through the below thread but left with no clue
    Pass URL parameters from WD to BSP via Post
    Here i have 2 Issues
    First one is --->
    " After pressing the Button I am calling this URL which is WDA for ABAP
          action="http://company/sap/bc/webdynpro/sap/zuser"> " I am calling WDA for ABAP URL here
    " Kindly guide me how to pass the Value
    Second one is -->
    " This value need to be passed to the URL above and
    " How to capture the Same in WINDOWINIT method of WDA for ABAP
    " And how to Capture this Value in Webdynpro INIT method
    "Here am using Form and method = post , I am removing this as it is causing some problem while posting
          action= my WDA For ABAP URL here " I am calling WDA for ABAP URL here
    " Kindly guide me how to pass the Value
    " This value need to be passed to the URL above and
    " How to capture the Same in WINDOWINIT method of WDA for ABAP
    Thanks and Regards
    Ramchander Rao.K

    Hi,
    let me see if I understand you well.
    BSP -
    You wrote the code for catching the user name in the event OnCreate, which means that you know who´s working with the BSP application when it starts.
    Somewhere you must have a button or something with text like "Call WDA application". When user presses the button, it triggers events OnInputProcessing. Here you must write the code for the cookie that "sends" the parameter(s), something like:
    CALL METHOD cl_bsp_server_side_cookie=>set_server_cookie
      EXPORTING
        name                  = 'MY_COOKIE'
        application_name      = 'ZUSER_NAME_GET'
        application_namespace = 'ZUSER_NAME_GET'
        username              =  sy-uname
        session_id            = 'SAME_FOR_ALL'
        data_value            = PAGE_DATA
        data_name             = 'PAGE_DATA'
        EXPIRY_TIME_REL       = 3600.
    you call then the URL for the WDA application.
    WDA -
    probably in method WDDOINIT of the component controller you´ll write the code for reading the "content" of the cookie:
    CALL METHOD cl_bsp_server_side_cookie=>get_server_cookie
      EXPORTING
        name                  = 'MY_COOKIE'
        application_name      = 'ZUSER_NAME_GET'
        application_namespace = 'ZUSER_NAME_GET'
        username              =  sy-uname
        session_id            = 'SAME_FOR_ALL'
        data_name             = 'PAGE_DATA'
    CHANGING
        data_value            = PAGE_DATA.
    read more about the cookies in SDN, because I am not sure if this is the correct example for transmiting values. I´ve used it in conjunction of instructions IMPORT and EXPORT for transmiting an internal table.
    if this is not working properly, then try with IMPORT TO MEMORY and EXPORT FROM MEMORY.

  • Passing parameter from servlet to Javascript url

    Hi all,
    I want to pass the value of a selected option box in servlet as a parameter to a url in JavaScript.
    my java script code is :
    out.println("function reloadform() { ");
    out.println("alert('aacat');");
    out.println("location.href = 'http://localhost:8080/examples/servlet/frec1?aacatt=aacat';");
    out.println("}");
    and servlet code is :
    out.println("<td bgcolor=#F2F9FF> <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform();'>");
    while (ra.next()==true) {
    String mycat=ra.getString("acat");
    String myasc=ra.getString("ascode");
    out.println(mycat+"<br>");
         out.println("<option value='"+mycat+"'><font face=verdana size=1>"+mycat+"</font></option>");
    Can anyone suggest me something on this ? Any Code reference will be highly appreciated.
    Thanks for any help in advance.
    savdeep.

    Please take care post the code in proper format...
    regarding the solution.. try something like..
    <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform(this.options[this.selectedIndex].value);'>");also change the javascript code suitably

  • Passing URL as attribute value  PROBLEM

    Here that is a problem
    I had responce.sendRedirect(
    http://167.230.25.121/wts/servlet/ProcessServlet?index=0&ScreenID=http://167.230.25.121/wts/servlet/PoliciesTransactio
    nLogServlet?isFromReport=yes)
    In old NAS 4.0 when i get
    responce.getAttribute("ScreenID")
    I recieve the whole parametr.
    in Tomcat 4.01
    I recieve NULL.
    I need to encode URL somehow and pass it as attribute value.
    I've noticed on Hotmail site MS does it tricky.
    http://209.185.240.250/cgi-bin/linkrd?_lang=EN&lah=d49440f3ef7bf6c2393bf11ff0c8e94e&lat=1012514523&hm___action=http%3a%2f%2fwww%2eWHERESMYREBATE%2ecom
    Can some1 advise , How to do that ? 10x

    What is involved here is to analyze the string and convert any non-alphabetic characters to what is known as escape character (% followed by a hexadecimal representation of the ASCII character).
    It is not that difficult to write a method to do that.
    V.V.

  • Problem while passing url's for URLRequest() class as parameter in Flash

    Hi all,
         I am calling java servlets from flash using the following code[below is a sample Flash code for calling a java servlet in Flash which I am using]:
    ...bla ...bla
    String url_String="http://localhost:8080/servlet/getViews";
    var req:URLRequest = new URLRequest(url_String);
    ...bla ...bla
    In this case, the servlet is called/working fine only in my system where the flash application is deployed & not working when I execute the application in different system using the "IPAddress" of my system.
    So, What changes I need to make in above Flash code in order to call the same servlet successfully from my system and as well as from other systems?
    (OR)
    Is there any need to pass the servlet-url's relative instead of absolute?
    If so,
    How can we pass relative-path of url's in Flash? &&
    Can anyone explain me with an example?
    Atlast, Can anyone tell me how to change my above code to pass the url 'relative' rather than 'absolute'?
    If I pass the url relatively, does my issue gets resolved?
    If, Please, can anyone help me by giving solution to my problem... [Or] else, to either of my queries or both...
    Thanks in advance...
    I am waiting for your replies...
    Srihari.Ch

    Did you read the ActionScript 3.0 documentation I linked to in my last post?
    var request:URLRequest = new URLRequest("XMLFile.xml");
    Example of using absolute URL:
    var request:URLRequest = new URLRequest("http://localhost:8080/servlet/getViews");
    Example of using relative URL:
    var request:URLRequest = new URLRequest("servlet/getViews");
    If the server port (8080) needs to be specified, you could declare a variable for the server URL and use it as a parameter.
    var serverURL:String = "http://localhost:8080/";
    var request:URLRequest = new URLRequest(serverURL + "servlet/getView");

  • Pass Parameter to Servlet

    How can i pass parameter from a JSP form (depends on what user chooses from a select box to a Servlet.
    I need to call multiple query based on what parameter choosen and display the result in table view.
    Example :
    1. User select choice1 from JSP form -> Servlet : call query Select * from Table1 where cond = choice1;
    2. User select choice2 from JSP form -> Servlet : call query Select * from Table1 where cond = choice2;
    Any sample code?
    Thanks for any help.

    Thanks melondck.
    I have this Servlet which i want it to run queries and display results in table format. I know there's something wrong with the code. But i am new to Servlet/Java. Thanks for anyone who point me the mistakes. Thanks.
    <code>
    package mypackage;
    import java.sql.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.servlet.*;
    public class DisplayServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse rsp)
    throws ServletException, IOException {
    rsp.setContentType("text/html");
    String url="jdbc:mysql://localhost/smdb";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String query;
    ServletOutputStream out = rsp.getOutputStream();
    PrintWriter out1 = rsp.getWriter();
    String answer = req.getParameter("answer");
    out1.println("<html>");
    out1.println("<head><title> Inventory: </title></head>");
    out1.println("<body>");
    if (answer == null) {
    StringBuffer action = HttpUtils.getRequestURL(req);
    out1.println("<form action=\"" + action + "\" method=\"POST\">\n");
    out1.println("<p><b>Please select:</b></p>");
    out1.println("<p><input type=\"radio\" name=\"answer\" " +
    "value=\"A\" /> Display All <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"B\" /> Device <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"C\" /> Manufacturer <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"D\" /> Location <br />");
    out1.println(" <input type=\"submit\" value=\"Submit\" /></p>");
    out1.println("</form>");
    } else {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection (url, "user", "mypass");
    stmt = con.createStatement();
    if (answer.equals("A")) {
    query = "SELECT Device, LocFloor FROM Inventory";
    esleif (answer.equals("B)) {
    query = "SELECT Device, LocFloor FROM Inventory where ....";
    ResultSet result = stmt.executeQuery(query);
    //Display the result set in a HTML table
    out.println("<HTML><HEAD><TITLE>List</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<FORM NAME='form' ");
    out.println("METHOD='GET'><TABLE BORDER='1' CELLSPACING='2' CELLPADDING='2'>");
    out.println("<TR><TH></TH><TH>Device Type</TH><TH>Floor</TH></TR>");
    while(result.next()) {
    String type = result.getString("Device");
    String flr = result.getString("LocFloor");
    out.println("<TD>" + type + "</TD>");
    out.println("<TD>" + flr + "</TD>");
    catch(ClassNotFoundException e) {
    out.println("Could not load database driver: " + e.getMessage());
    catch(SQLException e) {
    out.println("SQLException caught: " + e.getMessage());
    finally {
    //close the database connection.
    try {
    if (con != null) con.close();
    catch (SQLException e) {}
    out.println("</body></html>");
    </code>

Maybe you are looking for