get a value in the servlet with get, but null with post

S

Shiv

Hi,

I am getting a value for a hidden field in my servlet when the method
of the form is GET.
But when I change it to POST, I get a null value for the same field,
all things remaining the same.

Does anybody have any idea why this could be happening?

Thanks,
Shiv
 
S

Svetozar Radojcin

try to find article named "High-Level Network Programming ", here is one
part:
"....
Consider the following HTML form:

<form
action="http://www.javacourses.com/servlets/getMarks method="GET">
Student#:
<input type=text name=number size=30>
<input type=submit name=GetMarks value=GetMarks>
</form>

This form is handled by the servlet
http://www.javacourses.com/servlet/getMarks. The form uses
the GET method to transfer the information. When
the user enters a student number -- such as 556677 --
and clicks the GetMarks button, the form data is
sent to the servlet as part of the URL. The encoded URL
is:
http://www.javacourses.com/servlets/getMarks?number=556677.

In the case of POST, however, input data is not
sent as part of the URL; rather, it is sent as an entity body
in a separate message. Therefore, the POST method
is more secure, and you can send more data with it. In
addition, the data doesn't have to be in plain
text, as with the GET method.
.....

"
hope this helps...
 
J

John C. Bollinger

Shiv said:
I am getting a value for a hidden field in my servlet when the method
of the form is GET.
But when I change it to POST, I get a null value for the same field,
all things remaining the same.

Does anybody have any idea why this could be happening?

I'll make two wild guesses:

(1) the servlet is using custom code to parse the request's query
string, instead of using ServletRequest's parameter retrieval methods.

(2) the servlet is opening a stream from the request's body with
getInputStream() or getReader() before it tries to obtain the parameters.

If neither of those is it then we'll have to see some code.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top