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);

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.

  • Passing Idoc Control Record information  to JMS header

    Hi All,
    We have a requirement where we need to pass the 'MESCOD' and 'MESFCT" in the EDIDC_40 - Control record for the idoc to the Header of a JMS message.
    Basically we are trying to pass IDOC Control segment to the JMS header.
    I was looking at the options we have in the JMS adapter, and i am not sure how can this be achieved.
    Would appreciate any info on how this can be done.
    Thanks,
    Karthik

    Hi Karthik,
    As suggested by Ravi, you can hardcode this values in XI mapping before pushing data to JMS.
    Otherway round would be...check for User Exit where you can populate EDIDC_40 with MESCOD and MESFCT.
    Nilesh

  • 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.

  • OpenDocument - Can you pass input controls & other table columns

    I need your expertise.....In Webi XI 4.0
    I have used The OpenDocument URL to pass prompts as parameters...and that worked perfectly
    But now I want to pass input control as well...but now sure if this is possible
    and I would like to pass other columns in the table that are not part of my prompts
    e.g. I have 3 columns on my table
    i.e.
    Column name            Country Name     Provice       Number of Cities
    Column Data            South Africa        Gauteng           20
                                     South Africa        Mpumalanga    10
                                     South America     xxxxx              2
    The Country Name and Province are not part of my prompts....but I want to include them on my OpenDocument URL so that I can limit my data to that particular Country and Province.......
    Your help will be highly appreciated
    Thank you in advance

    As far as I know you cannot pass input controls to the opendoc. and the only way to restrict your child report with additional columns is to include them as filters. As there is no other way your child report would know that it should restrict the report with your column.
    Thanks,
    karthik

  • Passing Input Controls as Parameters in Webi

    Hi All,
    Hope you all doing great! I have a requirement where we need to pass input control values from Report A to Report B.
    As shown in the above image, the user selects 10 states (for example) at query run time and we have an input control for the same object ([State]) in the report where the user selects/filters four states out of 10 to view the Product and Sales information specifically for those states. Now from here we have a document linking setup on Product column to Report B where we see specific product information. (for example when user clicks on Shirts, Report B opens up with detailed info about shirts business in those four states that are selected via input control).
    So, my question is how do we pass these four states (selected via input control) from Report A to B. Please let me know how to implement this functionality. We are running on BO 4.1 with Teradata as backend.
    Thank you all for your responses. Cheers!!

    Hi Rakesh,
    It is working. Thanks for that. but it is also throwing #MULTIVALUE error for few fields. I don't know why but do you remember any instances that trigger this error? Any reason why I get this error?
    Well, what I see is one state has two products with same price. That is why it is causing multi value error. Any workaround for this?

  • 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

  • How can we pass the control from servlet to portlet ?

    Hi,
    we use PortletRequestDispatcher.include method to call the servlet.
    In my servlet, I have the following form information.
    out.println("<form method=\"post\" action=\"http://abc 40acce5.3a.com/portal/dt?display=Command\">");
    out.println("Enter value: ");
    out.println("<input type=\"text\" name=\"UserName\" value=\"\">");
    out.println("<center> "); out.println("<input type=\"submit\" value=\"Go Back Portlet\"> ");
    out.println("</center> ");
    out.println("</form>");
    When user click the submit button, the servlet will go to portlet first, then go to another page.
    is the url (action="http://abc40acce5.3a.com/portal/dt?display=Command) correct ?
    if not, what url we should use ?
    Can you help ?
    Thanks!

    Oh I thought that you have selection-screen and again you are working on dialog programming.
    if you want to use select-option directly in module pool then it is not possible.
    but you can do other way.
    create two varaiables
    data : v_kun_low like kna1-kunnr,
             v_kun_high like kna1-kunnr.
    use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
    and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
    use can enter only low value and high value.
    when you come to program point of view
    declare one range
    ranges r_kunnr for kna1-kunnr.
    do the coding like
    r_kunnr-low = v_kun_low.
    r_kunnr-high = v_kun_high.
    r_kunnr-options = 'BT'.
    r_kunnr-sign = 'I'.
    append r_kunnr.
    now you can use r_kunnr in select query ,it will work like select-option.
    other than this there is no option.
    Thanks
    Seshu

  • Pass query to servlet through midlet

    Hi, I have a problem here. I would like to control the SQL Statement to be executed by the servlet using the mobile midlet. Like this one:
    midlet -> will call servlet with parameter statement -> servlet will execute the statement parameter passed by the midlet and will return a data result in XML -> midlet will read the XML file and retrieve the data.
    Another thing I would like to ask is how will I make the servlet to output an XML file that can be read by the midlet. If there's some tutorial on how please give me the link.
    I hope you get my point.

    I have made to retrieve data on my midlet from my servlet. The bad thing is the data sent on the midlet has html tags. How will I make the midlet to just output the data result without the tags?If you are in charge of the servlet, then have it output plain text. If you need to parse the MIDlet input first, then having the content of XML/HTML elements will allow you to print them out.
    Is this servlet used from HTML browser as well? If so, try having a separate one for mobile devices. There are plenty options to do it.
    Daniel

  • How to pass parameters to servlet with POST with  Business Service OSB

    Hi all.
    I am newby in OSB. I am trying to send some values through a POST call to a servlet. I know how to call the servlet with Business Service of type "Messaging Service". I send the parameters of type Text.
    I have tried several ways, but I don`t find the proper way yo do it. I have tried to insert the param into the body and into the header.
    The problem is that I don`t know exactly where to put them, I don`t know if it must be done in the header or in the boy. I neither don`t know if there is a common way to do this.
    Please, could you give me a good example of an insert activity to isert a post parameter inside the call?
    For example: now I am using this one:
    Expression => "accountType=test"
    Location => as first child of"
    XPATH => empty.
    In variable => body.
    Where do I have to insert this, in the body or in the outbounds?
    I have followed this posts:
    https://blogs.oracle.com/jeffdavies/entry/enhanced_rest_support_in_oracl
    http://www.yenlo.nl/en/using-osb-with-rest/
    Thanks a lot.

    Hi,
    Please be carefull about passing values such as Strings or number that contains ',' .
    using the way described above.
    the best way is to pass an ID and then use a select Statement to get the other Values in the target page.
    regards
    MDK.

  • To pass Parameter to Servlet

    Hi,
    I have one servlet HTML page which gets the input from the user andon submittingthe form one mroe servlet is called which validates and dependig user value it will form the SQL select.
    Then I need to call Servlet which will generate an HTML page with the result set of the SQL.
    My problem is that from the processing form I need to send parameters and I am calling the final servlet usign forwardRequest. I formed the query string in teh form name=value and send the final string.
    I want to know whether they is any better way to achieve this.
    Please help me out!!!

    u can get parameters from the processing form using the HttpServletRequest.getParameter(String ..) method. once got into the first servlet on processing if u need to pass them onto the second servlet using the forward mechanism then u store these values into the HttpServletRequest.setAttribute(...) and using the getAttribute() methos can retrieve them in the other...

  • 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>

  • Cannot pass parameter to servlet

    dear all,
    I am writing a MIDlet to post some data to a servlet.At the MIDlet, i set as below:
    String url = getAppProperty("Login.URL");
    conn = (HttpConnection)Connector.open(url);
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    conn.setRequestProperty("Accept", "application/octet-stream" );
    conn.setRequestProperty("Connection", "close" );
    os = conn.openOutputStream();
    byte data [] = ("userid="+userid.getString()).getBytes();
    os.write(data);
    data = ("&password="+password.getString()).getBytes();
    os.write(data);
    os.flush();
    At the servlet, I coded:
    String id = request.getParameter("userid"),
    pass = request.getParameter("password");
    When i posted "userid=123&password=123" to the servlet, the servlet directed me to 'LoginFail.jsp' with below output:
    Login fail!
    null //should be print out userid and password value
    can anyone please give me some suggestions, why the servlet cannot locate parameter and how to solve it?
    thanx a lot!

    <p>wongyuenmei</p>
    <p>I've done some similar program. I'm not sure why request.getParameter() won't return the value we past. However, I managed to resolve the problem with the following way:</p>
    <p>Remain your MIDlet code. But change your servlets to use the following rather request.getParameter()</p>
    <pre>
    ServletInputStream sis = request.getInputStream();
    DataInputStream din = new DataInputStream(sis);
    String id = din.getUTF();
    String pass = din.getUTF();
    </pre>
    <p>Good luck!</p>

  • Best practice from passing messages from servlets

    Is there a best practice for passing user messages (typically errors) back to the page from servlets?
    e.g. http://localhost:4502/content/geometrixx/en.html?message=Some user error message
    Dan

    Well I suppose that answer to that question depends somewhat on your requirements, but I would say using a query string as you have indicated would be less than ideal because the page with the message would not be cached. No depending on your requirements and what sort of message you are passing that might be OK - especially if you message is highly personalized.
    If however you have a limited number of standard messages to display a more common approach is to have each message have it's own page and then to configure the servlet to redirect to the appropriate page based on the desired message.
    If you want the user to end up on the same page they submitted to the servlet from then another common approach would be to have the post to the servlet be AJAX and then display the message client side without having to change the URL.

  • Best way to pass values btwn servlets?

    i have to pass multiple values from one servlet to the next, when the user submits a form.
    i don't know how many, or even the names of the parameters until the user submits the form.
    right now, i send them as hidden fields when the form is submitted.
    in the receiveing servlet, i dump them into a hashtable usng httpUtils.parse QueryString, and then parse them out of the hashtable.
    is there a better way?
    TIA,
    Scott Murray

    DrClap,
    Yes, I am working with a single user.
    Last night I reworked it as follows, dumping the parameters into a Properties object, which is easier to work with than a hashtable (at least it is for me):
    Properties props = new Properties();
    Enumeration paramNames = req.getParameterNames();
    while (paramNames.hasMoreElements()) {
    String name = (String) paramNames.nextElement();
    String[] values = req.getParameterValues(name);
    props.setProperty (name, values[0]);
    The trick is that I don't know in advance the names or how many parameters are being received; I marked them on the sending page with different prefixes (@@@, ###, $$$) so as I parse thru the Properties object, I can determine what type of parameter it is.
    Is there a better object to use than the Properties object? My ultimate goal is to have something similar to a ResultSet that I can search and step thru multiple times.
    Thanks for you time and expertise,
    Scott Murray

Maybe you are looking for

  • Backup strategies for a small business?  Iomega Rev 70GB?

    hello.... Does anyone have any suggestions for a good backup solution for a small business? Our server holds about 30 GB of information, and we have been using those 8 GB DDS data cartridges, but so many tapes are required and it is not very efficien

  • How to create the Hierarchy Structure in BeX

    Hi, We have a cost center IOBJ MD, and our source system does not have the feasibility to create hierarchy to load it. But the business gave a hiearchy structure in flat file, and want to get the cost center hierarchy in bex. How do we do that ? Plea

  • I have problem with wireless print HP after iOS 7  !? What can i do

    I have problem with wireless print HP after iOS 7  !? What can i do?!  

  • EE are fraudsters and will never help with Credit Files

    EE, like many other businesses are complete fraudsters and do not have a clue what they are doing when it comes to customer service and dealing with Credit Files. They say they have Terms & Conditions but this is complete rubbish as they don't even k

  • Finder crashes frequntly

    Dear all, I am new to the Mac OS. I have severe problems with the finder. Once I click on a folder/device, the finder closes immediately and restarts again. In this case, all the remote connections are lost. This makes it very difficult to work;-). I