Request.getParameter problem

Did any one faced the problem please provide me a solution I am converting a project to WebSphere. using J2EE jsp 1.1 from NAS,jsp 0.92
I have a jsp page and I am submitting the form:
Test.jsp
<body>
<form name="frm" method="post" action="TestServlet">
<INPUT type="CHECKBOX" name="CKBXVCH23" value="A" checked>A
<INPUT type="CHECKBOX" name="CKBXVCH23" value="B" checked>B
<INPUT type="CHECKBOX" name="CKBXVCH23" value="C" checked>C
</form>
</body>
TestServlet:
when i do String str=request.getParameter("CKBXVCH23")
I am getting only str="A"
It suppose to give str=A;B;C because I have selected all the three items Its working fine in iPlanet, jsp 0.92
can anyone know whats the diffenrece.???
Thanks
zakir hussain

If you change the post to a get so you can see what is passed to the servlet you'll see the following parameters are passed:
CKBXVCH23=A&CKBXVCH23=B&CKBXVCH23=C
You need to use the
public java.lang.String[] getParameterValues(java.lang.String name)
mehod to get an array of all the values associated with "CKBXVCH23"

Similar Messages

  • Request.getParameter(): special character handling problem

    Hello, there:
    This should be an easy question for the gurus in here.
    I use a string attached to the url as the parameter string, which includes spaces. the system automatically converts them to %20, but when I receive them in my servlet using request.getParameter, a special character, &Acirc; appears; I couldn't proceed with it.
    I suppose this is a common problem but seems that I didn't find topics about it on this forum.
    So anyone can help? Any encoder/decoder APIs to handle it?
    Thanks a lot,
    Sway

    hi,
    escape can solve ur problem
    use js function to submit form like
    function subForm()
    var any_spcl_value ="kdfhjdf$%@#$% 2FGSFG @%@#%@# V";
    mainForm.action = "index.jsp?value="+ escape(any_spcl_value);
    mainForm.submit();
    and use request.getParameter("value");
    u ll get kdfhjdf$%@#$% 2FGSFG @%@#%@# V as it is.
    AE

  • 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

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

  • In JSP pages request.getParameter returns null

    There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
    Code :Ist jsp
    <BODY>
    <HEAD>
    function validate()
    document.add.submit();
    </HEAD>
    <FORM name="add" method="post" action=/dir/two.jsp" >
    <TABLE width="37%" border="0" align="center" class="c4f3">
    <TR>
    <TD class="c4">Rating</TD>
    <TD><input type=text name="rating"></TD?
    </TR>
    <TR>
    <TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    After the submit it goes to the 2nd JSP page .
    code:2nd Jsp
    <%
    String Rating=request.getParameter("rating");
    out.println(" Rating "+Rating);
    %>
    The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
    Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
    Thanks

    If I'am right you have misplaced the opening body-tag of your first jsp-page.
    The opening body-tag should follow after the closing head tag .
    The structure of your HTML-code should look like this:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

  • Servlets, request.getParameter()

    How do I test a servlet in Jdeveloper
    that wants a param from the calling URL, like
    http://.../servlet?myparam=myvalue
    via
    val=request.getParameter("myparam");
    I did already figure out, how to get init-Parameters, from
    webtogo.ora
    with
    getInitParameter();
    but that is not what I want, I want normal
    parameters.
    Running my servlet within jdev pops up
    a page with WebAppRunner.html in my Browser,
    that calls the servlet in jdev, I even tried handcoding my param there with no succes
    so far.
    Thanks for any help in advance.
    Rx
    null

    Hi Ganesh,
    Rx can u help me out on this.
    I have an applet that access a servlet and fetches information
    via a vector. The applet also sends the information via vector
    back to the Servlet. But the servlet fails to write into the
    database.
    Thanks in advance!!!Thank you for your confidence,
    I'm sorry for not being able to answer your question right away.
    * You might post some code examples,
    hopefully reduced to the minimum of what is
    needed to understand your problem.
    * You should consider opening a new thread
    as your problem seems only loosly related
    to mine.
    * I am just an Oracle JDeveloper user having
    gained some experience with jdev and the bc4j framework, but without the insight
    of the sourcecode.
    * You can however expect the people from
    the Oracle JDeveloper Team to be more
    responsive to user questions. - My general
    experience is, that the responsiveness
    in open source projects forums/mailing lists/newsgroups is much better. - They should be interested in their user's problems.
    Rx
    null

  • Jsp request.getparameter doesn't get querystring values

    We have recently deployed our jsp application which was running successfully on ias8i apache jserv into the 8.1.7 JVM and configured the mod_ose on the Oracle HTTP server every thing seems to be fine except the following case.
    Here we are accepting the userid,password from a jsp and submiting to the same jsp for action on submit we are reading a combination of jsp form feilds and url querystrings strangely we are able to get values only for the form feilds and querystrings return null.
    The same peice of code works fine on apache jserv implementation.
    Any clues please write to me.
    <SCRIPT Language="JavaScript">
    function check_password()
    document.Login.action ="problem.jsp?tab=YES&nSessionId="+document.Login.sessionid.value+"&nUserId=" + document.Login.userid.value;
    document.Login.target = "_top";
    document.Login.method = "post";
    document.Login.submit();
    </SCRIPT>
    <%
    userid = request.getParameter("userid");
    password = request.getParameter("password");
    tab = request.getParameter("tab");
    %>
    <form name="Login" Border="0" TopMargin="0" LeftMargin="0" Marginheight="0" Marginwidth="0">
    <table>
    <tr>
    <td class="FORMHEADERLEFTB"><b> Login</td>
    <td class="FORMHEADERLEFT">:</td>
    <td><input TYPE="TEXT" NAME="userid" SIZE="25" VALUE="<%=userid%> MAXLENGTH="10"></td>
    </tr>
    <tr>
    <td class="FORMHEADERLEFTB"> Password</td>
    <td class="FORMHEADERLEFT">:</td>
    <td><input TYPE="password" NAME="password" SIZE="25" VALUE="<%=password%>" MAXLENGTH="10" onChange="check_password()"></td>
    </tr>
    </table>
    <input type="hidden" name="sessionid" value="999999">
    </form>
    Thanks
    suresh
    null

    How are you retrieving the parameter values? I am able to retrieve parameters successfully using the following simple testcase:
    untitled1.jsp:
    <form method="post" action="servlet1">
    <P>Username:
    <input type="text" name="un"/>
    </P>
    <P>Password:
    <input type="text" name="pw"/></P>
    <P>
    <input type="submit" value="Submit"/>
    </P>
    </form>
    servlet1.java: (copy and paste from doGet() to doPost() method depending on value of form method in untitled1.jsp)
    String un = request.getParameter("un").toString();
    String pw = request.getParameter("pw").toString();
    out.println(un);
    out.println(pw);
    Please test this and let me know your results and the differences with what you are trying to do.
    Regards,
    Lynn
    Java Tools Team

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

  • Getting chinese charaters from Form using request.getParameter()

    Hi,
    I want my JSPs to be unicode enabled. In HTML forms user can enter any characters like japnese, chinese etc. But on the server side if user enters any such characters i am getting decimal equivalent of that character in the form of &#{decimal equivalent}; in the request.egetParameter() method.
    For ex if I enter �&#35234;&#35235;&#35271;&#35273;&#35333; then i get "&#9570;&# 35234;&# 35235;&# 35271;&# 35273;&# 35333;" in request.getPrameter().
    I have given the charset "UTF-8" in the header of my JSPs.
    I tried to decode it with URLDecoder but it fails then i tried to read these parameters using reader but it also fails, then
    String para = request.getParameter("para"); // where para is name of received parameter
    byte[] bytes = para.getBytes();
    para = new String(bytes, "UTF-8");
    This also fails.
    Can anyone please tell me how to handel this problem?
    Thanx
    -Vaijayanti

    Hi,
    I have tried this in my jsp and it works for me, assuming that the form is submitted with encoding UTF-8 :
    Submitting JSP :
    <form action="test.jsp">
    <input type="text" name="a">
    </form>
    This is test.jsp :
    <%
    String a = new String (request.getParameter ("a").getBytes (), "UTF-8");
    %>
    Passed Parameter = <%=a%>
    Hope that helps
    Thanks
    Amit

  • 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

  • Request.getParameter comes blank on some browser, while works on other

    Hi,
    Need urgent help to rectify thie problem
    I am accessing a application hosted on Weblogic8 SP2 as WAR file
    In this application I am able to login and search result and go to home page of one the search results.
    But on some other machine on same IE6 or Firefox the forward from search results to Home page stops in a URL which is being used in middle to forward.
    URL (also used in JSP pasted below) is created in action class called by search result link.
    This is how it is impleted.....
    I have a replicated link with unique Id on Search result page which forward me to this JSP
    <head>
    <SCRIPT language="JavaScript">
    function submitform()
    var urlString = "<%=request.getAttribute("urlString")%>";
    document.form1.action =urlString;
    document.form1.submit();
    </SCRIPT>
    </head>
    <body onload="submitform();">
    <form name = "form1" method = "POST">
    <input type = "hidden" name="myVariable" value="myValue"></input>
    <input type = "hidden" name="empID" value="<%=request.getAttribute("empID")%>"></input>
    <input type = "hidden" name="ownerName" value="<%=request.getSession().getAttribute("ownerName").toString()%>"></input>
    </form>
    </body>
    </html>
    Once this JSP is submitted this URL has to call a action class to validate some session attribute and the hidden value in JSP above named as "myVariable" which is checked for some "myValue". So it will then Forward to Home Page.
    On some machines IE6 or FireFox this is working as expected and logs show correct results all through.
    But some other machines with same Browser, the "myVariable" value in action class is coming blank and so request stops at the URL submit in above JSP. However no errors or Exceptions are thrown.
    Please help in this issue if some one can suggest any solution or way to dig up more on this.
    Also if I havent explained clearly by chance, then pls give me another chance to explain more.
    Thanks a lot for all your efforts.

    Hi,
    Thanks for reply,
    Nop our WAR do not have any filter. and We used IE 6 and FireFox 2 on both machines. We also saw the Options for both browser and matched these for both machines. They were same.
    The javascript we used was to submit the form on click of a Href. but it do not use any JSP element. We had just set a value in <input type="hidden"...
    and this value we fetch in Java class by saying request.getParameter("name");

  • Request.getParameter("_ROWKEY") returns null in JDev 3.2

    My SubmitEditForm.jsp uses a bean which inherits from the EditCurrentRecord data web bean. In JDeveloper 3.1 'request.getParameter("ROWKEY")' in this JSP returns the rowkey for the record being edited, but in JDeveloper 3.2 'request.getParameter("_ROWKEY")' returns null. No modifications have bean made to the application - the working JDeveloper 3.1 app has only been compiled in JDeveloper 3.2. Can anyone help please?

    Hi,
    This exception is raised when the multipart/form-data parser has read the number of bytes specified by the Content-Length HTTP header, or tries to read past the end of the input stream, but has not parsed to the end of the message. As implied by the error text, this can happen for a couple of reasons.
    Although its unlikely, it is possible for a client to sent an incorrect Content-Length header. However, we've so far only seen this with a user-written HTTP client. We have yet to see a browser send the wrong value.
    The usual reason for this error is if a user hits the stop button while submitting a form. If the browser has already sent the HTTP header, including Content-Type, then the parser will try to read the entire message. However, this is going to fail, as the browser stops sending the request as soon as the stop button is pressed.
    Finally, there is one more possible reason for this error, and that is if the request is somehow being 'munged' in some way between the browser and the servlet container.
    To help us better understand what is happening here, can you supply
    the following information:
    - Does this problem happen consistently or occur only randomly?
    - When it does happen, is it repeatable, or does it go away if the user hits the submit button again?
    - Does it happen with certain HTML forms, any HTML form, or is it specific to the data entered into a pariticular form?
    - Does it happen with any browser, or a specific version and/or implementation?
    - What is your network configuration? For example, does the problem occur only when going through a proxy server or fire wall.
    - Does it depend on network load? For example, does it happen only at heavy load times?
    - What is you web server configuration, on what platform are you running it, and what JDK version are you using?
    As I'm writing this, the TAR system is down for upgrades - my apologies if you've already supplied this information.
    Regards,
    Simon
    null

  • Request.getParameter() values in servlet? Urgent

    String str=request.getParameter();
    I am facing a problem when i submit the arabic values from hidden form fields using javascript.
    In servlet when i tries to retrive the arabic values stored in the session, it displays only
    garbage values(ie. ?????????).
    How to solve this problem?
    Please clarify and if possible give some samples.
    Thanks & Regards,
    Govindaraman

    Hi Govindaraman,
    in O'Reilly's Servlet book in the internationalization section it describes how. You have to change the String returned into bytes using the proper enconding, then back into a String to it will convert to Unicode.
    The basics are this:
    String parameterName="your param name";
    String encoding = "your charset encoding on the page";
    String value = request.getParameter(parameterName);
    value = new String(value.getBytes(), encoding);
    value is now a Unicode string that should be correctly interpreted.
    You can use new String( oldString.getBytes(), encoding) to convert between charsets.

  • Request.getParameter() from same page as HTML form

    I have a jsp page with a form. form contains a textfield, once the user submits the form, i want jsp scriptlet to get the
    value of the user input and carry out processing on it within the same page and give a result.
    problem is the first time the page is loaded, there is an error in the request.getParameter() statement since no form has
    yet been submitted i guess ....
    if i use another page ... it works ... but i want to display the information in the same page ...
    thanks

    I'd like to see an example where you'd get a NullPointerException from the line
    if(request.getParameter("foo") == null)
    but not one from
    if(null == request.getParameter("foo"))
    In either case, the only possibility for a NullPointerException would be if your request variable were null (but this would cause a NullPointerException in either method). Otherwise request.getParameter() returns a null value if the parameter does not exist, but will not throw a NullPointerException.

  • Illegal start of expression, request.getParameter

    Hello,
    I added the following to my jsp page
    <% String username = request.getParameter("username"); %>and an error pops up saying "illegal start of expression", am I missing something?
    Thanks
    EDIT: Problem solved, other code was causing the problem ;)
    Edited by: KyleG on Dec 17, 2008 3:18 AM

    import java.util.*;
    * Write a description of class PhoneCompany here.
    * @author (your name)
    * @version (a version number or a date)
    public class PhoneCompany
        private ArrayList<Account> accounts;
        private ArrayList<TextMessage> textMessages;
        private int collectRevenues;
         * Constructor for objects of class PhoneCompany
        public PhoneCompany()
            accounts = new ArrayList<Account>();
            textMessages = new ArrayList<TextMessage>();
            collectRevenues = 0;
        public void readAccounts(String fileName)
          String[] lines = LineIO.readAllLines (fileName);
          for (String line : lines)
            String [] a = line.split("&");
            if(line.startsWith("p")) {
                PrepaidAccount p = new PrepaidAccount(a[1], a[2], a[3], Integer.parseInt(a[4]), 30);
                accounts.add(p);
            if(line.startsWith("c")) {
                ContractAccount c = new ContractAccount(a[1], a[2], a[3], Integer.parseInt(a[5]), Integer.parseInt(a[6]), a[4]);
                accounts.add(c);
            System.out.println(line);
        public void readTextMessages(String fileName)
          String[] lines = LineIO.readAllLines (fileName);
          for (String line : lines)
            String [] b = line.split("&");
                TextMessage theTxtMsg = new TextMessage(b[1], b[2], b[3], b[4]);
                System.out.print(line);
        public int collectRevenues()  
            int total = 0;
            for (Account a: accounts)
                total += a.collectRevenue();
                System.out.print(total);
        return total;
    }

Maybe you are looking for