File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Sequence of request parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sequence of request parameters" Watch "Sequence of request parameters" New topic

Sequence of request parameters

Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
Hi ranchers,
1. Based on my experience with some servlets, I belive that there's no order by which request paremeters are sent. I'm using a simple servlet where I'm getting a java.util.Enumeration from ServletRequest.getParameterNames() method and then printing each param value. But, the params are retrieved but not in the order they were rendered by the HTML page.

2. GET is the default HTTP method. I have a servlet which doesn't overide the doGet() method. Pls. Consider the following two cases:

(a)When I post a form data which explicitly says METHOD=POST, I get the expected HTTP 405 error- method not supported.
(b) But, when I ommit any method, i-e METHOD= I don't get any error, instead the page gets refreshed. Why don't i get an error in this case also?

Any help shall be highly appreciated.

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You should ask separate questions in separate threads.

There is no default ordering for parameters. Even if you worked out how one server ordered them, you may find the next version ordered them completely differently.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Both observations are correct.

There is no defined order for request parameters.
Get is the default request type for a form submission.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

As for question 2, it is not difficult to debug a request through the Tomcat server, if you either looked at the code of the service method or attached a debugger it should help with the answer.

Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
Thanks rachers!
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Even if all browsers sent parameters in the same order as the HTML form, you would not be able to see that order because the HttpServletRequest parses them into a Map of some sort.

Consider Paul's rocket mass heater.
subject: Sequence of request parameters
It's not a secret anymore!