Distinguishing GET and POST paramaters in jsp

V

Vic

Hi,

Is there a better way to determine if a parameter came through
as a POST parameter rather than a GET one? The only way I can
see that you can do this is by examining the query string.

Thanks,

Vic
 
W

William Brogden

Hi,

Is there a better way to determine if a parameter came through
as a POST parameter rather than a GET one? The only way I can
see that you can do this is by examining the query string.

Thanks,

Vic

From the servlet API, it looks like the HttpServletRequest
method getRequestURL will do what you want. (I have not
actually tried this)

Bill
 
S

Sudsy

William said:
From the servlet API, it looks like the HttpServletRequest
method getRequestURL will do what you want. (I have not
actually tried this)

Even easier: HttpServletRequest#getMethod()
Should return "GET", "POST" or "PUT".
 
J

John C. Bollinger

Vic said:
Is there a better way to determine if a parameter came through
as a POST parameter rather than a GET one? The only way I can
see that you can do this is by examining the query string.

If you're worried about POST requests containing parameters in both the
query string and the request body then you must indeed examine the query
string to sort it out. Otherwise, though, take Sudsy's advice and just
check the request method.


John Bollinger
(e-mail address removed)
 
L

Luke Tulkas

Ben_ said:
What's the point ???

The point is that http parameters can be transfered by more than one method:
GET, POST, PUT. Sometimes it would be nice if server side knew how they were
sent. Generaly the .getMethod() takes care of that. But... you can have
method set to GET and send some parameters as the method suggests (as in
after "?" part of an URI) and some as POST (written directly onto output
stream of an http connection).
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top