Skip to main content

Servlet not getting POST data?

13 replies [Last post]
dailysun
Offline
Joined: 2007-02-20

Sorry, I have a few questions queued up but haven't been able to post them until now (and I've queried google and the forum to no avail :-( Sorry.

I have a very simple Web app on Glassfish 2 on Solaris 9. Web app is deployed to /mywebapp and is set to the virtual server's default context for /.

The Web app consists of one JSP and one servlet. The JSP has a form that submits (via POST) to the servlet. In the form, the JSP always sends a certain form value. When the Servlet receives the POST, it looks for the value. If the value is there, it knows that the request is coming from a form and starts processing the form. Since we moved to Glassfish 2, at random, the Servlet cannot find the POST data. At other times, the Servlet WILL find the POST data. Seems like the POST data sometimes is not presented to the Servlet. Could this have something to do with the settings for the virtual server's default context?

Do you have suggestions where I might look. This is a random problem, so I don't think it is specific to settings I might have in my Web application code.

dailysun

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dailysun
Offline
Joined: 2007-02-20
oleksiys
Offline
Joined: 2006-01-25

Hi,
can you pls. confirm that bug is still reproduceable with GFv2 b52 [1]?

Thanks.

[1] https://glassfish.dev.java.net/downloads/v2-b52.html

dailysun
Offline
Joined: 2007-02-20

So far, after changing the flag, we haven't experienced any similar issues. I'll monitor our system for another week and follow up. Thanks!

Jeanfrancois Arcand

glassfish@javadesktop.org wrote:
> So far, after changing the flag, we haven't experienced any similar issues. I'll monitor our system for another week and follow up. Thanks!
> [Message sent by forum member 'dailysun' (dailysun)]

Thanks. That means there is a bug in Grizzly. Can you file a bug and
attach a test case which I can use to reproduce the problem?

-- Jeanfrancois

>
> http://forums.java.net/jive/thread.jspa?messageID=209792
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

dailysun
Offline
Joined: 2007-02-20

Hi Jeanfrancois, Jan,

Thank you for your help. After changing the blocking-enabled flag to "true", we haven't experienced the issue again. Unfortunately, I cannot provide a test case - the issue occurred at random with the simplest of forms. I will include an example form script, but I assume that won't help. There appear to be entire periods where the problem comes up. I don't believe restarting the domain fixed the issue. Because the issue occurred at random, I cannot recreate it easily. Even when the issue occurred, I was not able to find error messages in the server.log log.

It may have something to do with our set up - the only "special" changes we made to the default glassfish 2 implementation was to add a self-signed certificate. Nothing else.

If you can suggest some possible ways to monitor and get appropriate logs when we experience the issue again, I'd be happy to post those resulting log outcomes. Unfortunately, the server.log which I monitored to find out what was going on did not show any problems :-(

I'll file a bug now.

THANK YOU for your help!

- dailysun

dailysun
Offline
Joined: 2007-02-20

Hi Jan,

The problem occurs randomly. Sometimes it happens, sometimes it doesn't. It doesn't seem to be tied to any specific form values entered. In one JSP, I have the form, i.e. (I left out the validate() javascript):

[code]




[/code]

In the other JSP, I do this:
[code]
String section = request.getParameter("section");
if(section!=null && section.equals("step2")){
// blablabla
}else{
System.err.println("Error - no form values received");
}
[/code]

At random, the section variable (and therefore, I assume, the entire form data) is not received and I get my System.err message. This is the standard form. I don't see any exceptions or errors in server.log. Is there another place where I can monitor this problem?

dailysun

Jeanfrancois Arcand

Hi "dailysun",

can you change the http-listener blocking-enabled="false" to
blocking-enabled="true" and see if that fix the problem? If that fix the
problem, file a bug with a test case and assign it to .... me :-)

Thanks

-- Jeanfrancois

glassfish@javadesktop.org wrote:
> Hi Jan,
>
> The problem occurs randomly. Sometimes it happens, sometimes it doesn't. It doesn't seem to be tied to any specific form values entered. In one JSP, I have the form, i.e. (I left out the validate() javascript):
>
> [code]
>

>
>
>
>

> [/code]
>
> In the other JSP, I do this:
> [code]
> String section = request.getParameter("section");
> if(section!=null && section.equals("step2")){
> // blablabla
> }else{
> System.err.println("Error - no form values received");
> }
> [/code]
>
> At random, the section variable (and therefore, I assume, the entire form data) is not received and I get my System.err message. This is the standard form. I don't see any exceptions or errors in server.log. Is there another place where I can monitor this problem?
>
> dailysun
> [Message sent by forum member 'dailysun' (dailysun)]
>
> http://forums.java.net/jive/thread.jspa?messageID=208886
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

dailysun
Offline
Joined: 2007-02-20

Thank you! I've updated the configuration and will monitor whether the problem occurs again.

dailysun
Offline
Joined: 2007-02-20

Hi Jan,

You are right. What I wrote about the query string was gibberish - that was just for testing, but I didn't figure correctly that the POST will not include values in the query string. In the actual Servlet, I get the form data using the standard request.getParameter("xyz") format (which is set by the default servlet code to work with POST and GET).

So, I agree - the fact that the query string does not show anything is not determinative. But the problem exists even with request.getParameter("xyz").

dailysun.

Jan Luehe

glassfish@javadesktop.org wrote On 03/09/07 05:54 PM,:

>Hi Jan,
>
>You are right. What I wrote about the query string was gibberish - that was just for testing, but I didn't figure correctly that the POST will not include values in the query string. In the actual Servlet, I get the form data using the standard request.getParameter("xyz") format (which is set by the default servlet code to work with POST and GET).
>
>So, I agree - the fact that the query string does not show anything is not determinative. But the problem exists even with request.getParameter("xyz").
>
>

I'm unable to reproduce this, i.e., getParameter() returns the POSTed
form parameter, as expected,
regardless of whether I access the webapp at "/" or its designated
context root.

Could you send your test case so I can take a look?

Thanks,

Jan

>dailysun.
>[Message sent by forum member 'dailysun' (dailysun)]
>
>http://forums.java.net/jive/thread.jspa?messageID=207207
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

dailysun
Offline
Joined: 2007-02-20

Another followup message. I've now accessed my Web app at its direct URL /mywebapp. When I submit the form there, the servlet has twice RECEIVED the POST data. When I went back to acccess the Web app from the default vs context /, the servlet does NOT get the POST data. This could be chance, but I've tried it twice back-to-back with the same results.

Is the default vs-context properly forwarding POST requests to the Web application which is deployed to /mywebapp (actually, the app name is /actionplans)

dailysun

Jan Luehe

glassfish@javadesktop.org wrote On 03/09/07 09:14 AM,:

>Another followup message. I've now accessed my Web app at its direct URL /mywebapp. When I submit the form there, the servlet has twice RECEIVED the POST data. When I went back to acccess the Web app from the default vs context /, the servlet does NOT get the POST data. This could be chance, but I've tried it twice back-to-back with the same results.
>
>Is the default vs-context properly forwarding POST requests to the Web application which is deployed to /mywebapp (actually, the app name is /actionplans)
>
>

The fact that your webapp has been designated as the virtual server's
default-web-module
will not interfere in any way with the requests sent to it.

Assume your FORM's action looks like this:

If you access the FORM like this:

http://:
/actionplans/form.jsp

the FORM's input will be submitted to

http://:
/actionplans/MyServlet

and if "actionplans" has been designated as the default-web-module of
, and you access the FORM like this:

http://:
/form.jsp

its input will be submitted to

http://:
/MyServlet

which is mapped (internally by the container) to

http://:
/actionplans/MyServlet

From an earlier email, it seems you are trying to access the FORM
params via the request's
query string. This will work only if your FORM is submitted with
METHOD=GET, but not
with METHOD=POST. In the latter case, the FORM params will be sent in
the request
body, instead of being appended as a query string to the request URL.

Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

dailysun
Offline
Joined: 2007-02-20

What I have done to debug is to print out certain request data within the Servlet. Here is the result:
[code]
[#|2007-03-09T09:03:36.140-0800|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=11;_ThreadName=httpSSLWorkerThread-443-0;_RequestID=4078e93d-50ff-4b1a-b446-2e09193c1a4a;|
Query String: null|#]

[#|2007-03-09T09:03:36.141-0800|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=11;_ThreadName=httpSSLWorkerThread-443-0;_RequestID=4078e93d-50ff-4b1a-b446-2e09193c1a4a;|
Header Names: org.apache.tomcat.util.http.NamesEnumerator@181fc6c|#]

[#|2007-03-09T09:03:36.141-0800|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=11;_ThreadName=httpSSLWorkerThread-443-0;_RequestID=4078e93d-50ff-4b1a-b446-2e09193c1a4a;|
Request URI: /actionplans/AuthController|#]

[#|2007-03-09T09:03:36.141-0800|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=11;_ThreadName=httpSSLWorkerThread-443-0;_RequestID=4078e93d-50ff-4b1a-b446-2e09193c1a4a;|
Request Servlet Path: /AuthController|#]
[/code]

In the log above, you'll see the various request entries I check. You'll see that the query string is empty.

dailysun