JSP request.getParameter bug

i try the following code for receive Parameters from jsp.
<% String name=request.getParameter("Name"); %>
but when Name TextField(in HTML) is empty and i want to check
for none empty field with (if) instruction with following code..
if(name ==null ) //somecodes..
this instruction not run and programs continue .

It's not a bug.
<%
String name=request.getParameter("Name");
if (name == null) {
  //what to do if parameter does not exist
  //e.g.: a checkbox not checked
} else if (name.trim().equals("")) {
  //what to do if parameter exists but is 'empty'
  //e.g.: an text input field with no non-whitespace characters
  //NOTE: if you want leading and trailing spaces to be
  //      considered values, remove the .trim() from the condition
} else {
  //there is a value.. do with it as you will
%>

Similar Messages

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

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all,
    i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
    Output :
    FILE NAME : TEST
    FILE PATH : test.txt
    Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileReader.<init>(FileReader.java:55)
    at com.test.TestServlet.processRequest(TestServlet.java:39)
    at com.test.TestServlet.doPost(TestServlet.java:75)
    JSP CODE:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DEMO SERVLET</title>
    </script>
    </head>
    <body>
    <h2>Hello World!</h2>
    <form name="myform" action="TestServlet" method="POST"
    FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
    FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
    <input type="submit" value="Submit" name="submit" />
    </form>
    </body>
    </html>
    Servlet Code :
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    String filename = request.getParameter("filename");
    out.println(filename);
    String filepath = request.getParameter("myfile");
    out.println(filepath);
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TestServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
    if (filepath != null) {
    File f = new File(filepath);
    BufferedReader br = new BufferedReader(new FileReader(f));
    String strLine;
    String[] tokens;
    while ((strLine = br.readLine()) != null) {
    tokens = strLine.split(",");
    for (int i = 0; i < tokens.length; i++) {
    out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
    out.println("----------------");
    out.println("</body>");
    out.println("</html>");
    } finally {
    out.close();
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    Needed Output :
    FILE NAME : TEST
    FILE PATH : C:\\Temp\\test.txt
    Any suggestions Plz??

    As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
    You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html].

  • Request.getParameter in jsp

    Hi!
    in my jsp code , i am reading a value from select box and submitting the form to a jsp page.
    My jsp reads the selected value of the select box and displays some values.
    This seems working for me as i am using request.getParamater("my_selectbox_name"); in my jsp.
    i have one search button in the same jsp which reruns the same jsp....
    here i am getting null value from my select box.
    i tried to replace the select box with hidden and assigned a fix value to the same.
    then i replaced the request.getParameter as request.getParameter(my_hidden_name);
    this works fine as far as the first submit of form, but returns null if i click my search button in my jsp.
    any help pls...

    Hi! there,
    huuff ...!
    at last i found the way it should work.. thanks to jgalacambra for discussing this , otherwise i may given up..
    Ok.. let me explain how it worked for me.
    My code is now with 3 files
    a.html b.jsp and c.jsp
    a.html submits the select value to b.jsp which is smooth.
    now search option is available in b.jsp and searched output is now appearing in c.jsp frame.
    Thanks a lot, dude.
    girish

  • 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

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

  • Null value in Session vars and request.getParameter

    We're migrating our application from iPlanet.
              Under iPlanet, when we looped through a resultset and set the values to
              session variables - it worked fine, even when a resultset value was null,
              but in WebLogic, I get the following error:
              java.lang.IllegalArgumentException: key/value is null
              Is there anyway to "turn this off" so it behaves like iPlanet?
              My second question is that we have many JSP's that check to see if a
              parameter is null in javascript:
              Here's the code:
              function onLoad() {
              document.form.elements[0].focus();
              // Check to see if the user is coming from a shortcut
              var imageName = "<%=request.getParameter("imageName")%>";
              if (imageName == "null") {
              selectTop("<%=select_image%>");
              } else {
              selectTop(imageName);
              <% if (tableIndex == 2) { %>
              loadShortcutIcon(13,100);
              <% } %>
              in iPlanet, when the parameter "imageName" is not in the URL, the javascript
              variable gets set to "null" - but in WebLogic, it is set to a blank string -
              "". Is there anyway to make this return null like iPlanet?
              Thanks,
              Matt
              

    Hi,
    the URL parameter is added just for the request to the page. When you press the command button then you issue a new request that does not have a URL parameter added. To work around this, you can use a PhaseListener that stores the URL request parameter in the session for later use
    Frank

  • In Portal, request.getparameter return NULL (Sample Monthcalendar)

    I used the sample monthcalendar. When i used it without integrated in portal, i can change month by month with ">>" button.
    In the JSP File, there is a call to the P_CALDATE parameter
    String l_inputDate = request.getParameter("P_CALDATE"); // Input Date.
    When i put this JSP file as an URL Portlet, i can't navigate month by month. the function request.getParameter("P_CALDATE") return NULL, but in the URL i have the parameter:
    http://hddms220.cg63.fr/servlet/page?_pageid=54,58,56&_dad=portal30&_schema=PORTAL30&P_CALDATE=2002-05-01.
    Someone have an idea
    Thanks in advanced

    I have tested the sample with JSERV, and all works fine.
    But if i wan't use OC4J/ORION to display a portlet how can i do it.
    Thanks in advanced

  • Geting null vaules with request.getParameter().....

    Hello Experts,
    I am sending a data from one jsp page to another using java script (document.form.txtbx.value = myData), on same page I cheked and got the correct value but on the next page, I am getting null vaues. I am giving my code just check out and give me suggetions..
    On button click I am calling function jfun_submit(..,..,..,..)
    function jfun_submit(mhCd , scheme , dhCd , dhnm ,  total , grantNo , noOfBill  ,grossAmt , n_p , totAMT , dept , c_v , type , grossAmtQtr , addAmount , LOC , flagnext , neg_flg , neg_amt_alwd,tansend,appNosend,appDatesend , loc)
      var getLink =mhCd+"|"+scheme+"|"+dhCd+"|"+total+"|"+grantNo+"|"+noOfBill+"|"+grossAmt+"|"+n_p+"|"+totAMT+"|"+dept+"|"+ c_v+"|"+type+"|"+grossAmtQtr+"|"+addAmount+"|"+"Budget"+"|"+flagnext+"|"+neg_flg+"|"+neg_amt_alwd+"|"+loc+"&Tan="+tansend+"&AppNo="+appNosend+"&AppDate="+appDatesend;
    document.bill.getLink.value= "";
    document.bill.getLink.value = getLink;      //setting the value to the txtfield
    alert("After Set : "+document.bill.getLink.value);  //shows alert correctly.
    var url="BillSchemeCheckX.jsp
    document.bill.action=url;
    document.bill.method="POST";
    document.bill.submit();
    {code}
    and on next jsp page me writing following code
    {code}
    String getLink = request.getParameter("getLink");
    out.println("GetLink Value : "+getLink);
    {code}
    the result displying GetLink value : null
    Please help me out                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    What is the html for the formfield 'getLink'? I am guessing you have the id parameter set which makes this bit work 'document.bill.getLink.value = getLink;' but you dont have the name parameter set so your request.getParameter isnt working.

  • Submitting request.getParameter value on page submit

    I am getting the value from the request parameter as under
    <%
    String mod = request.getParameter("mod");
    %>
    Now i want this mod value to be submitted as page submits. For that i used:
    <h:inputHidden id="mod_field" value="" />
    Now the question is how to pass the above mod value using this hidden input? and secondly how to bind it with the property in the backing bean (say the name of my backing bean is bean.navigation) so that i can access and use the value.

    Hay this exception has again started showing me up.
    exception
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.tsheetRcode_jsp._jspService(tsheetRcode_jsp.java:344)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    root cause
    javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
         javax.faces.component.UIOutput.getValue(UIOutput.java:147)
         com.sun.faces.renderkit.html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:670)
         com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:549)
         com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:525)
         com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:481)
         com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
         javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:712)
         javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:616)
         javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:539)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doEndTag(SelectOneMenuTag.java:505)
         org.apache.jsp.tsheetRcode_jsp._jspx_meth_h_selectOneMenu_0(tsheetRcode_jsp.java:449)
         org.apache.jsp.tsheetRcode_jsp._jspService(tsheetRcode_jsp.java:263)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

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

  • 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

Maybe you are looking for

  • Flash problem persists after 6 months...does this new information help?

    Hi All! I posted my problem almost 6 months ago, (I'll paste some of the info below to bring you up to date), but I STILL can't access only FOUR sites because I get a "Plugin file is missing" error, (after my previous post I found 2 other sites).  I'

  • How do I change the registration name on a new Macbook Pro?

    My daughter just got a Macbook Pro and had filled in the registration info with her name and address but my other daughter told her it had to me my name and changed it all and registered it under my name.  My daughter, of course, wants it under her n

  • Video not playing correctly but sound on the videos does

    Hey all. Question for you. Recently my iPod has decided to stop playing the videos shows. The display only shows a picture of the show title (much like the cover art of songs) and the audio plays as if it were playing normally. The files seem good be

  • Sorting issues

    I'm trying to become M$ free and committed to convert all my excel files to Numbers. I have a column with a time value in it - I'm try to sort it is ascending order. It's a mess - doesn't work. I tried a work around and converted the time to it's equ

  • Has anyone else experienced this same problem?

    Whenever I press the menu, forward, back, play and pause buttons my ipod does what the middle button is supposed to do. When I press Menu it won't take me to the menu. When I press play or pause it won't play or pause. When I press forward or back it