I think all the servlet engines will handle this identically... they'll
see that the method of the form was "POST", and consequently look to the
post data rather than the querystring for any parameters. I suppose you
could have all servlets check both the querystring and post data, but
this seems like extra processing for something that isn't very
frequently used.
Here are 2 solutions
:
1. Call javax.servlet.http.HttpUtils.parseQueryString
(request.getQueryString ());
This will return a Hashtable of the query string parameters. Then for
post data you'd use the standard request.getParameter (""), and for
query string data, you'd use this hashtable. This is probably your best
bet.
2. Include any query string parameters as hidden elements in your form.
Change your html from what you have below to:
<form method="post" action="response.jsp">
<input type="hidden" name="name" value="value">
<input type="submit" value="Hello">
</form>
I think the better is more elegant, but I remembering running into
situations where that just isn't practical. Hope these suggestions
help.
Serge Knystautas
Loki Technologies
http://www.lokitech.com
Bill Lipa wrote:
>
> I'm using Apache 1.3.4 and JServ 1.0b2 on Win32. I'm trying to use a GNUJSP
> page to respond to an HTML form. Unfortunately, I've run into a problem that
> may be a bug in JServ, or it may just be my lack of understanding of POST
> requests.
>
> The form:
> <form method="post" action="response.jsp?name=value">
> <input type="submit" value="Hello">
> </form>
>
> Inside the processing for the response.jsp compiled servlet:
> request.getQueryString() = name=value
> request.getRequestURI() = /local/dir/response.jsp
> request.getParameter("name") = null # !!!?!?!
>
> Since the JSDK doc states under the doc for getParameter, "in an HTTP servlet
> this method would return the value of the specified query string parameter," I
> think the return result of request.getParameter("name") above should be
> "value".
>
> Changing the form so that the method is "get" rather than "post" causes things
> to work correctly.
>
> I need to get access to both form response data and URL query parameters.
> What am I missing? Thanks for any help.
>
> Bill Lipa
>
> ----------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html/>
> Problems?: [EMAIL PROTECTED]
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]