wood burning stoves*
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
Author

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.

Thanks,
Reema
David O'Meara
Rancher

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
Sheriff

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
Rancher

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.

Dave
Reema Patel
Ranch Hand

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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sequence of request parameters