Retriving only hidden parameters from request.getParameter

Hi,
I want to retrive only the hidden parameters from previous JSP page into current JSP page. The problem here is that my hidden parameters in privious page are dynamically generated (parameter names are decided based on values retrived from the database) and I cannot retrive them using "request.getParameter(<parametername>)"
Can I find the parameter type (i.e. text box, text area, checkbox, radio or hidden) from the request.getParameter() or request.getParameterNames() methods? or is there any other way to find it.
Thanks in advance for any help

You can use the getParameterNames() or getParameterMap() methods from javax.servlet.ServletRequest to get all the parameters in the request. Even if they're dynamically generated, and you don't know the names in advance, these methods will ferret them out.
getParameterMap() returns name String, values String [] pairs, so you'll have to work with String arrays to get the input out. It's got to be that way to accomodate checkboxes and other HTML form elements that can send more than one value for a given name.
I prefer getParameterMap, because I don't like using Enumerations as much. - MOD

Similar Messages

  • How do send along hidden parameters from a form action method

    Hi,
    I have a JSP that displays an HTML form with several input types such as cehck boxes, radio buttons, text field and read only text fields. The read only fields are populated from a database. There are also a few hidden parameters that come in from the requesting JSP.
    Now, when I have entered values in the input fields and click on SUBMIT, I want the action to lead to another jsp which will validate the entries and also want the hidden parameters in the html page sent and also want the read only values sent to the validating JSP ....how do I accomplish this ?
    Please help !
    mahesh

    Hmm...I did exactly that in my target jsp..where I used request.getParameter("MODE") where MODE is the key that I had passed into the html using an earlier jsp:forward command....something like "inputform.jsp?&MODE=ADD.....etc.
    but my request.getParameter("MODE") returned null.
    When you say properly formatted within the form and /form tags, I wonder if you could tell me what I need to do to format hidden parameters that have been passed along from an earlier request ?
    Thank you very much,
    Mahesh

  • Accessing parameters from request header in init()

    Hello
    How can I access parameters passed on the client request header like
    http://localhost:8080/servlet/DBServlet?database=mydatabase
    from the servlet initialization method ini()
    The getInitParameter() only returns parameters defined in the web.xml file (if is this correct).
    I would like to use the getParameter() from the request class, how can I do this within init()
    Thanks

    Greetings,
    Hello
    How can I access parameters passed on the client
    request header like
    http://localhost:8080/servlet/DBServlet?database=mydat
    base
    from the servlet initialization method ini()You can not. As you pointed out, the init() method is for servlet initialization - it is called by the container to allow the servlet to prepare to receive requests, which are then passed to the service() method.
    The getInitParameter() only returns parameters defined
    in the web.xml file (if is this correct). That is correct - parameters can be defined in the deployment descriptor in either the <servlet> level (passed to the servlet in ServletConfig), or the <webapp> level (passed to the entire webapp in ServletContext).
    I would like to use the getParameter() from the
    request class, how can I do this within init()Again, you can not - there simply is not any client communication during initialization.
    ThanksRegards,
    Tony "Vee Schade" Cook

  • How to get Int value from request.getParameter()?

    Hi all,
    I have a integer value which is passed from one page to another page.
    i am geting this value in the next page using
    request.getParameter().
    Eg.
    Suppose value of "i" in page1 is 32, i pass this as hidden variable to next page.
    <input type="hidden" Value="<%=i%>" NAME="limit">
    in page2, i fethch this value to a variable by name "limit"
    String limit=request.getParameter("limit");
    but, since value stored in limit is int, i can't assign it to string.
    i can't use request.getParameter for int values.
    How to solve my problem.
    I know it is simple,
    Pls. help me
    Regards
    ASh
    String limit=request.getParameter("limit");

      String limitSTR = request.getParameter("limit");
      int limit = -1;
      if (limitSTR != null) limit = Integer.parseInt(limitSTR);

  • Not able to get the full value from request.getParameter()

    hi all,
    Iam giving a text input value as" Analysis and tracking" in one jsp form.
    while fetching and assigning the value to another variable using request.getparameter , iam getting only the text "Analysis" , the space after it were ignored andnt displaying it.
    Help me in solving this.
    thanx
    Balaji

    I think you are code is something like this
    <input name="xyz" type="text" value=<%=variable%>>
    HTML ignores spaces. Therefore you are only getting Analysis, the first word, when your browser encounters the first space it ignores whatever is present after that.
    One way of overcoming this is putting double quotes around the text value
    <input name="xyz" type="text" value=<% out.println("\"" + variable + "\""); %>
    Thanks.

  • How to read parameters from request object

    We want to read parameters from GET request
    but whenever we are calling GET_URI_PARAMETER from the REQUEST we don't see any results
    url is like
    http://coevi116.wdf.sap.corp:8000/sap(bD1lbiZjPTEwMA==)/bc/bsp/sap/z_test_json/jsontest.htm?PARAM=ABC
    But reading PARAM is not givng value of ABC
    onCreate and onRequest wherever we put the code it is not reading the value
    Can anyone please help and share some expert opinion

    in jsontest.htm page create a page attribute named "PARAM" with auto check box checked and check in oninitialization, this will carry the value passed to param from url.

  • Get all values from request.getParameter

    In ASP, I can do something like that...
    For each item in Request.Form
    Response.write "Name is:" & item & " value is:" & Request(item)
    Next
    How about in JSP? How do i get the names and values of the form using a loop?

    You can use request.getParameterNames() which will return an enumeration, then you can iterate through the enumeration and use request.getParameterValue(String paramName) method to get the values.

  • Newbie request.getParameter(String) issue

    I'm having an issue setting a boolean value in a bean based off a string from request.getParameter(). I've created a small example to illustrate what I want to happen:
    testForm.jsp:
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>testForm</title>
      </head>
      <body><form method="POST" action="testWork.jsp">
          <input type="hidden" name="hiddenTest" value="1"/>
          <input type="submit" name="submitTest" value="Submit"/>
        </form></body>
    </html>testWork.jsp:
    <jsp:useBean id="test" scope="session"
                 class="thistestapp.testClass"/>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>testWork</title>
      </head>
      <body>
      <%
      out.print("<p>" + request.getParameter("hiddenTest") + "</p>" );
      // Great it's sending "1"
      test.setTestB(request.getParameter("hiddenTest"));
      //So when I set this in the bean I should get true
      out.print("<p>" + test.getTestB() + "</p>" ); 
      //False? Not nice!!
      test.setTestB("1");
      //Alright there must be an issue with my code in the bean, so hardcode a
      //"1" in.  I should still get false.
      out.print("<p>" + test.getTestB() + "</p>" );
      //True?? I hate you.
      %>
      </body>
    </html>testClass.java:
    package thistestapp;
    public class testClass {
        private Boolean testB;
        public void setTestB(String testB) {
            if ( testB == "1"){
               this.testB = true;
            else{
               this.testB = false;
        public Boolean getTestB() {
            return testB;
    }So, I want when the bean is sent a "1" from the form to set the bean value to true. I however can't get that to happen. I'm sure there's something I'm missing.
    TIA.
    Joe

    ? if ( testB == "1"){
    Standard beginner's error. If you want to test if two strings contain the same text, use the equals() method. Like this:if ( testB.equals("1")){Your code tests whether the two sides of the == operator refer to the same object. It's possible and likely for two different strings to contain the same value, which is what you are really interested in.

  • Clearing variable from Request object

    Hi everyone,
    After getting value from request.getParameter("var"), I want to clear this "var" variable from request scope. So that in the next coming statements if i again call the same request.getParameter("var") statement than it must return null
    So how to handle this issue of clearing certain variable from request scope or flushing the whole request object

    I don't know what you are trying to do but it sounds confused. I would suggest you read the parameter once, at the beginning of the code. Store it in a variable and use that variable as necessary. If you still need help then would you explain what you are trying to achieve here.

  • WHY? Request Parameters From Form are NULL

    I have the following process, which by the way has been working successfully for months, until just recently.
    1) User comes to JSP page to upload images through a form that has the <input type="file"> fields as well as <input type="hidden"> to hold a few essential values.
    2) User submits form, form action attribute set to go to a Servlet
    3) Servlet reads all request params and inserts the images into a database.
    I have code to read in the images...I use classes from the org.apache.commons package.
    I could only assume it was the servlet that was the problem, but doubted that because why would it work all these months than suddenly stop.
    I set up a test html page with a form and had it go to a jsp page to read the request params and print them out. To my suprise they all had NULL values.
    Which tells me that the params aren't being read from the form.
    How could this be??
    Here is some example code snippets from my test pages:
    HTML PAGE
    <html><body>
    <form name="images" action="testing_operations.jsp" enctype="multipart/form-data" method="post">
    <input type="hidden" name="Customer_Number" value="4750">
    <table>
    <tr><td>
    <input type="file" name="image1" />
    </td></tr>
    <tr><td>
    <input type="file" name="image2" />
    </td></tr>
    <tr><td>
    <input type="submit" value="submit">
    </td></tr>
    </table>
    </form>
    </body>
    </html>JSP PAGE
    String cus = request.getParameter("Customer_Number");
    out.println("cus : " + cus +"<br>");
    String image = request.getParameter("image1");
    out.println("image: " + image); 
    I'm stumped...what am I doing wrong?
    I can't continue until I get this figured out, can anybody help me with this?
    Message was edited by:
    Love2Java

    I ran my original app with the enctype and without it:
    the tomcat dos-prompt that shows exceptions lists out this below...
    org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed.
    C:\jakarta-tomcat\temp\upload_00000009.tmp (The system cannot find the path specified)
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:429)
    at org.apache.jsp.testing_operations_jsp._jspService(testing_operations_jsp.java:113)The code on line 113 in testing_operations.jsp is:
    List items = upload.parseRequest(request);
    and what is this .tmp file its trying to find?? I'm passing it an image off my local disk, not a .tmp file, there isn't even a temp folder in my jakarta-tomcat main folder....
    It is failing on this line because it isn't reading the request parameters sent in, thus why too when I test for the values of the params they return null.
    True, when I take out the enctype my test page will show the values, but this doesn't help me. I need that enctype attribute in there to process the images sent in through the fields.
    So where does this leave me??
    I went to the apache site for the commons upload and they have a more current version than what I'm using which is version 1.0, they have 1.1.1
    I downloaded the new version but had no success in using it, the compiler couldn't find a class I attempted to use.
    I still don't understand how this could be working and then suddenly stop.

  • Request.getParameter("blah") from within a class?

    Hi Everyone,
    Not sure if I'm missing something...
    I'm trying to create a class that will examine and parse information from a form, and then pass it to another class that knows how to handle the input.
    A request in the form of http://www.domain.com/stuff.jsp?1=param1&2=param2&4=param4
    stuff.jsp only has this:
    UrlRequestGetter params = new UrlRequestGetter();
    out.println(params.getTheParams());and the general idea for the UrlRequestGetter class is this:
    public classUrlRequestGetter {
         public String getTheParams(){
              String request1 = request.getParameter("1");
                    String request2 = request.getParameter("2");
                    String request3 = request.getParameter("3");
                    String request4 = request.getParameter("4");
    }Within that class, there will be various actions to check whether or not fields are empty, etc. The big point is that i'm trying to do a request.getparameter from within a class. When i try to compile, I get:
    cannot find symbol
    symbol:variable request
    Any thoughts?
    Thanks!

    Take a step back from all that, and read the error message: cannot find symbol: symbol:variable request
    Is "request" a variable you have declared or passed into your method getTheParams() ?
    Where is it supposed to get the request from?
    "request" is an implicit variable to your JSP. If you want to use it in your bean, you have to pass it as a parameter.
    I'm trying to create a class that will examine and parse information from a form, and then pass it to another class that knows how to handle the input.You might consider using the <jsp:setProperty> tag to map parameters to bean attributes automagically.
    Or the BeanUtils.populate method provided by Jakarta Commons BeanUtils.
    Or any framework like struts, jsf, spring, stripes....
    Cheers,
    evnafets

  • Polish characters are not retrived from request object

    Hi
    I have a problem in passing POLISH character through request object.
    I am calling a servlet from a jsp with a hyper link. when the link in jsp is clicked the following code will be executed
    response.sendRedirect(response.encodeURL("http://hostname:8080/appName/abc.do?method=getReport&FirstName=Ko�tun&LastName=Pro�ciak"));
    this code is passing two POLISH strings First Name & Last Name to the servlet.
    In the servlet i am trying to retrieve the values of the parameters "FirstName" & "LastName".
    Sring FN=request.getParameter("FirstName");
    String LN=request.getParameter("LastName");
    The variable FN & LN doesn't show the POLISH character in servlet.
    I tried with the below option in JSP
    <meta content="text/html; charset=ISO-8859-2" > (or)
    <meta content="text/html; charset=UTF-8" >
    (or)
    <%@ page contentType="text/html;charset=ISO8859_2" %>
    (or)
    <%@ page contentType="text/html;charset=UTF-8" %>
    In Servlet i tried using
    request.setCharacterEncoding("ISO-8859-2");
    (or)
    request.setCharacterEncoding("UTF-8");
    Pl help me.
    Thanks in advance

    Don't do it then. Those characters are not allowed inside a URL and have to be encoded. You know, that %... stuff.

  • In WL6.1 request.getParameter returns NULL for URL parameters that exist

              With the following URL, I get different results between WebLogic 4.5.1 and WebLogic
              6.1:
              http://phx-kmccarthy.medspecialists.net/tsweb/ParametersTest.jsp?apple=macintosh&tree&dog&country=USA
              Weblogic 6.1 returns:
              query string = apple=macintosh&tree&dog&country=USA
              apple = macintosh
              tree = null
              dog = null
              country = USA
              WebLogic 4.5.1 returns:
              query string = apple=macintosh&tree&dog&country=USA
              apple = macintosh
              tree =
              dog =
              country = USA
              here is the jsp...
              <%--
              * ParamtersTest.jsp which shows that empty parameters are ignored in WebLogic
              6.1
              --%>
              <%
              String apple, tree, dog, country;
              apple = request.getParameter("apple");
              tree = request.getParameter("tree");
              dog = request.getParameter("dog");
              country = request.getParameter("country");
              out.println("<br>query string = " + request.getQueryString());
              out.println("<br>apple = " + apple);
              out.println("<br>tree = " + tree);
              out.println("<br>dog = " + dog);
              out.println("<br>country = " + country);
              %>
              From the documentation on the getParameter() method:
              Returns the value of a request parameter as a String, or null if the parameter
              does not exist.
              In my opinion, not existing and being empty are different. Also, every other web
              application environment we've dealt with (including WebLogic 4.5.1) treats them
              as different. If the parameter doesn't have a value, (i.e. ...&tree&dog&...) then
              getParameter() returns the empty string, not null.
              As a result of this we have JSPs that break when running on 6.1.
              

    Found the solution at last. Tomcat servlet container can't handle the chunked transfer-encoding that the J2ME Wireless Toolkit uses when you call outputstream.flush() in midlet. Using outputstream.close() instead of outputstream.flush() will avoid this problem for small requests. For all the codes in the articles on Http Post in Wireless Forum, don't use outputstream.flush() and it will run perfectly - Servlet's request.getParameter(parameterName) will work fine in doPost method.

  • NullPointer exception in request.getParameter().indexof(.....) only in 6.1

    Hi
    I have one full working application (containing WAR + JAR) files.
    Right now this application is working absolutely fine in weblogic 6.0 sp1 on
    WINNT & Solaris.
    In this application, we accept events to save data from external
    applications like excel files.
    Now code in JSP is -->
    Line 1: String Data = request.getParameter("data");
    Line 2: Data.indexof(........);
    Now in case of weblogic 6.1, i am getting NullPointer Exception in line 2,
    but I am NOT getting any exception in case of weblogic 6.0sp1.
    To my surprise, I am also printing request obj parameters values, whenever
    jsp get called from external source, there it is printing value of "data".
    I am totally clueless!!
    Any idea plz?
    Ashish Jain

    Looking very closely at request object contents..
    Wht i am sending (posting) from excel file-->
    xmlData=<?xml version="1.0" encoding="UTF-8"?><reportSheet bu="SHKXXX"
    report="PBrandContr" sheet=
    "PBrandContr" year="2002" coType="A" status="0" brId="PIC" act_brId="PIC"
    opt="P" ></reportSheet>
    But 6.1 interprets like this ---->
    key is --------> xmlData=<?xml version="1.0" encoding="UTF-8"?><reportSheet
    bu="SHKXXX" report="PBrandContr" sheet=
    "PBrandContr" year="2002" coType="A" status="0" brId="PIC" act_brId
    And Value is -------> "PIC" opt="P" ></reportSheet>
    This thing is causing all problems.
    I am not observing this kinda behaviour in 6.0sp1.
    Thanks
    Ashish Jain
    "Ashish Jain" <[email protected]> wrote in message
    news:[email protected]..
    Hi
    I have one full working application (containing WAR + JAR) files.
    Right now this application is working absolutely fine in weblogic 6.0 sp1on
    WINNT & Solaris.
    In this application, we accept events to save data from external
    applications like excel files.
    Now code in JSP is -->
    Line 1: String Data = request.getParameter("data");
    Line 2: Data.indexof(........);
    Now in case of weblogic 6.1, i am getting NullPointer Exception in line 2,
    but I am NOT getting any exception in case of weblogic 6.0sp1.
    To my surprise, I am also printing request obj parameters values,whenever
    jsp get called from external source, there it is printing value of "data".
    I am totally clueless!!
    Any idea plz?
    Ashish Jain

  • Getting parameters from multipart request

    I'm using org.apache.tomcat.utils.fileupload to parse uploaded files from a multipart form, but unfortunately I can't seem to get normal parameters from such a form with request.getParameter(). Is there a way to use both together?

    You might already have solved your problem, but you may find this MultipartFilter useful too: http://balusc.blogspot.com/2007/11/multipartfilter.html
    It automatically detects multipart/form-data requests and sets the plain vanilla form parameters back in the ParameterMap of the HttpServletRequest and sets the files as attributes of the HttpServletRequest. This way there is no need to worry about the form encoding type inside the servlet.

Maybe you are looking for

  • ASA 5520: Create Network Object for range of hosts?

    Hi, I'm new to Cisco Firewalling. I'm migrating our network objects from our current firewall to a new ASA 5520 configuration. I'm using ASDM 6.4 for configuration. We have a range of IP addresses for hosts that we need to add to a firewall rule/ACL.

  • Reporting multi-currency on reports, without hardcoding the exchange rates

    I've seen this problem posted in a few different spots, and the general answer is, reporting only reports in a single currency per report. Unless you do some calculations in a column to get a new currency value. Problem... 1. we dont really want to h

  • Error loading prefs

    Everything in my console.log as "error loading prefs - creating defaults one" at the end of it. What does this mean, and what do I do to fix this problem. I have already re-set my pref folder, but that seems to not do

  • Strange behaviour on joins

    Hi, Please try following example: create table a (id integer, name varchar2(200)); create table b (id integer, nameb varchar2(200)); create view vv as select * from a where id < 100; a) select name from a join vv on vv.id = a.id this query will retur

  • I deleted my photos in my ipad4, any way to get it back?

    I deleted my photos in my ipad4, any way to get it back?