users@glassfish.java.net

Re: Servlet not getting POST data?

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 09 Mar 2007 12:31:45 -0800

glassfish_at_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:

  <FORM ACTION="MyServlet" METHOD=POST>

If you access the FORM like this:

  http://<server>:<port>/actionplans/form.jsp

the FORM's input will be submitted to

  http://<server>:<port>/actionplans/MyServlet

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

  http://<server>:<port>/form.jsp

its input will be submitted to

  http://<server>:<port>/MyServlet

which is mapped (internally by the container) to

  http://<server>:<port>/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