aspose file tools*
The moose likes JSP and the fly likes Request parameter is missing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Request parameter is missing" Watch "Request parameter is missing" New topic
Author

Request parameter is missing

David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
I have a very difficult problem:
One of my JSP pages has some parameters (hidden fileds and text fields) in form. When this page submits (get or post) to another page, the new page sometimes can't get the parameters from request object.
And it just happens several times among thousands successful operations.
I use iPlanet 4.0 + Weblogic 6.1 SP5.
The server is hosted in Solaris 6.5 machine.
Have I explained my question clearly?
This is a very serious issue in our product environment.
Any reply will be hightly appreciated.
Thanks!
[ March 12, 2004: Message edited by: Bear Bibeault ]
[ May 04, 2004: Message edited by: Bear Bibeault ]

David,<br />SCJP - 94% (2002-7-6)
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Are the fields static or dynamic (created on the fly).
If the latter there might be some condition in your code preventing the form from containing those fields, causing the problem you describe.


42
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Is it always the same parameter or just "some" random parameter that's missing every now and then?
One thing you could do is to put up a TCP sniffer of some sort to log the HTTP requests to the server and wait until you get that corrupted request. Then, see whether the HTTP request contains the parameter (if it doesn't, the problem is at the client, if it does, the problem is in your code or in the application server).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Thanks Jeroen.
All the fields are static.
I write them directly in the JSP.
<input type="hidden" name="nic" value="ts sss">
Will the space in the value field cause some trouble?
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Hi Lasse Koskela
All the parameters will disappear every now and then.
I have log all the message and I have log the following two methods:
System.out.println(request.getHeader("Referer"));
System.out.println(request.getParameter("nic"));
The log message is:
/pd.jsp?nic=hello
null
This is very curious here: Why the getHeader() method can get the full url with parameters, but getParameter() can't get the parameter?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by David Li:
I have log all the message and I have log the following two methods:
System.out.println(request.getHeader("Referer"));
System.out.println(request.getParameter("nic"));
...
This is very curious here: Why the getHeader() method can get the full url with parameters, but getParameter() can't get the parameter?

That is because the HTTP header "Referer" tells you the previous page the client requested, not the URL for the current request.
For example, if you're browsing http://www.javaranch.com and click a link to http://www.javaranch.com the HTTP GET request sent to saloon.javaranch.com will contain an HTTP header "Referer: [url=http://www.javaranch.com/".]http://www.javaranch.com/".[/url]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Are you doing a response.sendRedirect() ? :roll:


Groovy
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Could you show us how you make the request in the JSP?
Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Ramana Kumar Atmakuru
Greenhorn

Joined: Jul 13, 2003
Posts: 6
hi David Li,
I hope,you definitely know when to use GET and when to use POST.I guess,the problem would be that you might be using GET as your from submission method and you are trying to send more data than allowed with GET.It does matter whether you use GET or POST.with GET,we can send only limited amount of data but with POST,it is unlimited.
I suggest to change your method to POST and let me know what happens.i also have some other answers for you if this my current guess is not correct.
TakeCare,
bye
Ramana Kumar Atmakuru
SCJP,SCWCD.
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Thanks Lasse Koskela,
It's really a new knowledge for me.
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Hi Pradeep Bhat,
I have two projects that meet this issue.
One is using respone.sendRedirect(),
The other only use <form>...</form>.
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Hi Nick,
//pd1.jsp
<form action="pd2.jsp" method="post">
<input type="hidden" name="nic" value="hello">
<input type="text" name="sex" value="male">
<input type="submit">
</form>
After user click submit button, this is the process jsp:
//pd2.jsp
<%
System.out.println(request.getHeader("Referer"));
System.out.println(request.getParameter("nic"));
System.out.println(request.getParameter("sex"));
%>
The log message is:
/pd.jsp?nic=hello&sex=male
null
null
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Hi Ramana Kumar Atmakuru,
As you can see in the above message I just posted, I use POST method.
And yes, I know that GET method can only has less than 2K parameters in IE but my project use POST method instead.
Hope for your other answers!

And sorry for the delays to all!
I can only access internet in office.
BTW, this is the greatest forum in the world!
I have posted this message in many other forums, only this forum has response.
David Li
Ranch Hand

Joined: Aug 12, 2002
Posts: 41
Can anyone gives some advice?
Thank you in advance.
I have also asked this question in jGuru:
http://www.jguru.com/forums/view.jsp?EID=1154341
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
When you lose a parameter, do you lose all of them? If so, it's possible that users are cutting and pasting your URL into another browser window - or even posting them on the web for others to click on - which would result in all the POST parameters being lost.
Not necessarily the most likely thing, but perhaps a possibility.
Warren
Kristofer Sommestad
Greenhorn

Joined: Mar 30, 2004
Posts: 2
Hi there guys,
I've had the exact same problem with a web application and have searched every corner of the web for an answer...
It's a payment GUI where some parameters get lost and it's always the same parameters. They get lost in between the different pages (between which I POST data).
The forms are posting (with POST, of course) to different "events" (in a servlet) and I know that the parameters aren't empty when posting the form. The event dispatches to another JSP-page by using res.sendRedirect(), as someone asked.
Everything is performed on https.
The parameters are numbers (no spaces or other characters).
I try to request the parameters with a simple req.getParameter("[paramName]").
It always works properly locally but does sometimes (about 1 time out of 30) screw up when I let it go live...
It is always the same parameters and only those amongst several others who are lost sometimes.
Could it be an https-issue?
Please help me out here!
Thankful for any reply!
Peter Kreuser
Greenhorn

Joined: Apr 01, 2004
Posts: 4
We are coming across the exact problem at this moment. It does not occur during our testing and not for all of our customers.
We use the exact same method - POST to new window, and the environment is also https! Browser in the special case is IE 6, protocol is HTTP/1.1
As far as I remember, I have come across this problem a long time ago. Unfortunately I cannot remember. Getting old .
May have been something with the use of a proxy...
I will post here if I find the reason and/or a possible solution.
Any help appreciated.
Thanks
Peter
Peter Kreuser
Greenhorn

Joined: Apr 01, 2004
Posts: 4
Me again:
To add: we use a form to POST and in the recipient build a new form with a target that comes from the parameterlist:
<%
String cZiel = request.getParameter("i_cZiel");
%>
<....:html on'L'oad='document.forms[0].submit();'>
<form name="wait" action="<%= util.makeStaticURL(request, cZiel) %>" method="GET">
<%
Enumeration enum = request.getParameterNames();
StringBuffer queryString = new StringBuffer();
while (enum.hasMoreElements()) {
String tmp = (String)enum.nextElement();
if(!tmp.equals("i_cZiel")) {
%>
<input type="hidden" name="<%= tmp %>" value="<%= java.net.URLEncoder.encode(request.getParameter(tmp)) %>">
<%
}
}
%>
The enum in this case is empty!!!
Raj Etta
Greenhorn

Joined: Apr 07, 2004
Posts: 3
We are facing the same problem - not all, but only few (yet to determine pattern - we'll putting additional logs ) request parameters miss.
Environment: Apache webserver , weblogic 7.0 and all submits are POST & HTTPS (Is it that it's specific to HTTPS requests? )
Beat De Martin
Greenhorn

Joined: Apr 15, 2004
Posts: 2
I have the same problem, my environment is Tomcat, Apache Webserver and https. Clients are mostly IE 6.
It happens once a week but I can't fiure out what it is ?
Michael J�rgens
Greenhorn

Joined: Apr 20, 2004
Posts: 3
Hello,
I�ve the same Problem with WinXP (Client), IE6, Apache 1.3, Tomcat 4.1 and HTTPS on Suse Linux 8.2 (Server) and POST requests.
I can reproduce the symptom on my Workstation when I make a request from the generated Page after a timeout of aprox. 30 seconds. If I make the request immediatly after the page has loaded it is all ok.
With timeout I lost all POST request parameters. With GET there is no problem.
It is crazy, but on another workstation nearly the same configuration and exactly the same browser it is not possible to reproduce the symptom.
Peter Kreuser
Greenhorn

Joined: Apr 01, 2004
Posts: 4
Michael: How and where do you provoque the timeout. However I try I can not reproduce the problem.
I have tried to delay the submit of the form, or put a Thread.sleep in the called page. No success
Beat De Martin
Greenhorn

Joined: Apr 15, 2004
Posts: 2
Hello Michael
I've got exactly the same environment, what do you mean with provoking timeout ?
My system is used by 50 clients and this error happens only once in a while but is very fatal as you can imagine.
Has it something to do with IE6 ?
Michael J�rgens
Greenhorn

Joined: Apr 20, 2004
Posts: 3
OK, my english is not so good
What I mean ist the following:
IE6 gets a response, display it, user fills out the form, send to server (jsp)
This is ok. But:
IE6 gets a response, display it, wait 30 sec., user fills out the form, send to server (jsp)
Than the POST Data will not receive the JSP.
I don�t know where this Data will be lost.
In IE6?
In mod_jk ?
In Tomcat Servlet Engine ?
Or in JASPER JSP Engine ?
There is no problem, if I change the transfer to GET.
It is not so easy to find out, beacause it happens only with HTTPS
May be it is a problem with http headers?
Doesn anybody know a tool like live-http-header from mozilla for IE6?
regards,
Michael
Peter Kreuser
Greenhorn

Joined: Apr 01, 2004
Posts: 4
We use HTTPWatch from http://www.simtec.ltd.uk.
Pretty good tool
Michael J�rgens
Greenhorn

Joined: Apr 20, 2004
Posts: 3
I put the interface serializable into all my session relevant classes.
And now I haven�t the problem any more.
May be it is a hint for other peaoble.
Regards,
Michael
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
I've had this problem a couple of times and it was due to...
  • The user's session timed out and they were requested to re-authenticate. After this, for some reason, the container lost the original request parameters.
  • The character encoding of the request didn't match the response. For example, I was expecting the parameters in UTF-8 and they were being transmitted by the browser in ISO-8859-1 (or vice versa, I don't remember).


  • Of course, it could just be a bug somewhere in your container implementation. :roll:
    Jonathan James
    Greenhorn

    Joined: May 06, 2004
    Posts: 1
    We have been having the same symptoms ya'll have described only with Jboss 3.2.3/Tomcat 4.1.29
    Don't know if you guys have made any progress, but it appears that this is actually an IE6 bug related to keepalive. Here are some links with more info:
    News thread
    Microsoft
    A workaround is to disable keepalive on the server.
    Dumitru Husleag
    Greenhorn

    Joined: Oct 01, 2003
    Posts: 22
    I didn't have your problem but I recommend you all to use some tools to watch the http or https frames.
    I worked with SnifferPro and CommView. I'm sure this will help you find the problem or at least getting closer to it.
    Good luck


    Dumitru
    Kristofer Sommestad
    Greenhorn

    Joined: Mar 30, 2004
    Posts: 2
    Yes, Jonathan, that seems to be the exact problem.
    I solved it by using GET instead of POST in my pages, which works fine for me. But I recall something about GET not being so secure as POST or whatever.
    But I'm still glad since the problem is gone...
    Good luck, fellas!
    Simon Benzekri
    Greenhorn

    Joined: May 12, 2004
    Posts: 1
    Did you try to set your parameters as session objects. Not an ideal solution but it might work. One more question are U preventing caching ?
    I.E:
    <%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
    %>
    Simon
    A Sun
    Greenhorn

    Joined: May 13, 2004
    Posts: 1
    Iv been having the same problem,im using tomcat4.1 and im testing a project on both IE5.5 and IE6. GET works for both but when i switch to post it will only work with IE6,the parameters get lost on IE5.5 and show 'null'
    Iv tried changing the charsets but it hasnt worked
    Any ideas?
    Duncan Simpson
    Greenhorn

    Joined: May 27, 2004
    Posts: 1
    I've been having a similar problem but with HTTP not HTTPS, therefore the IE problem mentioned above is not the cause (according to MS it only affects HTTPS).

    Scenario 1: Request content length is -1, QueryString parameters available, form parameters not.
    Scenario 2: Request content length is a positive number, QueryString parameters available, form parameters not.
    Scenario 3: Request content length is a positive number, QueryString parameters available, and only SOME form parameters are available.

    I managed to solve scenario 1 . It was caused by the user clicking refresh after getting the IE error 'The page cannot be displayed', because there is no longer a form to post. (FYI the IE error was caused by a faulty Cisco cache engine).

    However, I'm still getting scenario's 2 and 3.

    It seems to be a random problem that is only occuring in our Production system. 99% of the time the request from this page works fine. I can't replicate it in our dev/test environments, therefore I can't put a sniffer on to diagnose it. I can't put a sniffer on Production as the volume of data would be astronomical.

    I've checked the request's Content-Encoding and its coming through as ISO-8859-1, which is what we set in our JSPs. I've checked the referrer and the user is coming from the page that does contain the correct form.

    I've tried everything I can think of

    Has anyone had this variation of this problem? If so, any ideas?
    David Li
    Ranch Hand

    Joined: Aug 12, 2002
    Posts: 41
    It's very exciting for me because I found so many similar errors as mine.
    My error also happens intermittently and only happens in production mode.

    Thanks Duncan!
    With your great help, I found it is a bug of webcontainer.

    For WebSphere, you can download the following patch:
    IBM PQ76884
    http://www-1.ibm.com/support/docview.wss?&uid=swg24005684
    IBM PQ76013
    http://www-1.ibm.com/support/docview.wss?uid=swg24005688

    For Weblogic6.1 + iPlanet4.0 (This is my environment), you should update iPlanet4.0 to iPlanet6.0SP2.
    BEA CR085169
    http://e-docs.bea.com/wls/docs70/notes/issues.html

    For other AppServer, I think you can find the solution if you search the word "post" in your AppServer's support website.


    Thank you all!
    This is really the most wonderful forum in the world!
    Oleg Kirillov
    Greenhorn

    Joined: Jun 07, 2004
    Posts: 1
    //pd1.jsp
    <form action="pd2.jsp" method="post">
    <input type="hidden" name="nic" value="hello">
    <input type="text" name="sex" value="male">
    <input type="submit">
    </form>

    After user click submit button, this is the process jsp:
    //pd2.jsp
    <%
    System.out.println(request.getHeader("Referer"));
    System.out.println(request.getParameter("nic"));
    System.out.println(request.getParameter("sex"));
    %>

    The log message is:
    /pd.jsp?nic=hello&sex=male
    null
    null


    I guess problem is here:
    <form action="pd2.jsp" method="post">
    You set method to "post", not "POST". The size, i.e. case does matter! If you try to look at http traffic you'll notice that really your browser used a GET method on this form as it parsed method attribute incorrectly.

    In my case the situation is much worse.
    I use Oracle Container for Java (OC4J) and when I use POST method to send form parameters I cannot retrieve any parameters. All of them are "null" no matter what browser I use. Also - I sniffed my HTTP traffic and I see that POST method works and it uses a correct enctype (enctype="multipart/form-data") to send parameters. I've tried Tomcat 4.12 - it shows the same result. The code is:
    <%@ page contentType="text/html"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html">
    <title>untitled</title>
    </head>
    <body>
    <form action="testenc2.jsp" enctype="multipart/form-data" method="POST">
    TXT<input type="TEXT" name="txt" size="50" value="text1"/><br>
    MLTXT<textarea name="mltxt" rows="10" cols="50">TA test</textarea><br>
    <input type="HIDDEN" name="tst" value="test"/>
    <input type="SUBMIT"/>
    </form>
    </body>
    </html>

    The POST operation sends the following data:
    ---------------------
    POST http://192.168.32.122:8989/DemokitsII-Viewer-context-root/testenc2.jsp HTTP/1.1
    Host: 192.168.32.122:8989
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
    Accept-Language: ru,en-us;q=0.7,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Proxy-Connection: keep-alive
    Referer: http://192.168.32.122:8989/DemokitsII-Viewer-context-root/testenc1.jsp
    Cookie: JSESSIONID=c0a8207a231dc0874bc6e16f4a7cad0cc8f6131e8c95
    Content-Type: multipart/form-data; boundary=---------------------------6483275954041
    Content-Length: 490

    -----------------------------6483275954041
    Content-Disposition: form-data; name="txt"

    text1
    -----------------------------6483275954041
    Content-Disposition: form-data; name="mltxt"

    TA test
    -----------------------------6483275954041
    Content-Disposition: form-data; name="tst"

    test
    -----------------------------6483275954041

    ---------------------

    ALL request attributes are null. Looks like I missed something...
    [ June 07, 2004: Message edited by: Oleg Kirillov ]
    Benoit de TARADE
    Greenhorn

    Joined: Jun 08, 2004
    Posts: 1
    I had the same issue last week!

    This was due to difference between dev and prod environment.
    On dev network we use Tomcat and on prod Websphere.

    On Tomcat we can use request.getparameter() function anywhere in the code.
    On Websphere have to be used on the top of the JSP page.
    Carey Schmitt
    Greenhorn

    Joined: Jun 30, 2004
    Posts: 1
    Originally posted by Oleg Kirillov:

    I guess problem is here:
    <form action="pd2.jsp" method="post">
    You set method to "post", not "POST". The size, i.e. case does matter! If you try to look at http traffic you'll notice that really your browser used a GET method on this form as it parsed method attribute incorrectly.


    Actually in XHTML it's clearly defined that the only valid values for method are "post" and "get". It is not valid XHTML to use the uppercase versions. But in reality, browsers ignore the case of the method attribute, perhaps except for some VERY old versions ...

    Thankyou everyone for this thread, this problem has been driving me nuts lately because I couldn't work it out! I thought it must have been a problem with the web container (Sun One Appserver), I should have suspected IE right from the start.

    PS> Has anyone worked out a method to consistently replicate this problem? It seems random to me, sometimes it's very hard to simulate it. It would be good if I could replicate it at will.
    [ June 30, 2004: Message edited by: Carey Schmitt ]
    Lixin Han
    Greenhorn

    Joined: Jul 13, 2004
    Posts: 2
    hello, sir
    we have same problem like yours. Our enviroment is Tomcat + Apache. If we send request quickly, can get request. If we are waiting some time to send request(10-15 seconds), lose it.

    we find our problem, maybe it can help yours.
    Old Code for reponse is :

    res.setContentLength(html.length());
    res.setHeader(...........)
    res.setHeader(............)
    out = res.getWriter();
    our.println(html);

    Solution:
    we just delete "res.setContentLength(html.length());"
    then all work fine. We don't know what reason of that? Maybe by using HTTP protocol something wrong in the client side (Browser). Can somebody explain the reason ?
    Lixin Han
    Greenhorn

    Joined: Jul 13, 2004
    Posts: 2
    Hello, Sir
    The reason of using reponse.setContentLength() is : in some book it explains it can increase perfomence. But I think it only for downloading big data to client and not for html format
    Bzz Huh
    Greenhorn

    Joined: Sep 06, 2004
    Posts: 1
    This is for anyone coming here from a search engine.

    If your posts are constructed programatically and do not come from a browser then make sure they are URL encoded properly. We had a parameter with an LRC of % (the last character in the parameter value) coming in about once a month messing everything up.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Request parameter is missing