Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange post data order

Status
Not open for further replies.

simonTheTraveller

Programmer
Jun 29, 2006
16
0
0
GB
Hi all. I've got a jsp class handling the display of a load of post data variables. In the previous page, I've got about 6 select controls each with data.

I've got to the stage where, when the form is submitted, the next page retrieves all the post data and displays the select control data in new select controls. This is for a summary type page where the user can review what they've done.

However, the post data doesn't seem to be in any order at all! Its not reversed or back to front or anything. It just seems random. I need to keep the select controls in the same order.

Does anyone know why the data should be reordered when its posted?
And does anyone know of a way to order the data in the way I want?

Cheers, Simon
 
Hi

Simon said:
However, the post data doesn't seem to be in any order at all!
Do you mean the list returned by ServletRequest.getParameterNames() is unordered ?
The only solution I can imagine is to handle the data manually. I do not think anyone else would base anything on such order. At least I definitely not.

Feherke.
 
yeah. I'm using the getParameterNames method to retrieve all the options in numerous select controls. Can you suggest any other way to get all this data? regards, Simon
 
I don't think the order is guaranteed. What about giving names to your controls?

Cheers,
Dian
 
Hi

Simon said:
Can you suggest any other way to get all this data?
I already suggested ( Ok, was in half words ) :
Feherke said:
The only solution I can imagine is to handle the data manually.
For POST method would look like this :
[ul]
[li]The [tt]getReader()[/tt] method will return a [tt]BufferedReader[/tt] from which you can read the body of the request. There are the POST -ed data.[/li]
[li]The [tt]getContentType()[/tt] method will tell you the MIME type of the request body. That is how the data is organized.[/li]
[/ul]
Not tried, just theory.

But better consider redesigning your code.

Feherke.
 
thanks a lot everyone. Sorted it out now. Since I need to manipulate the data in order to create a report, I created a class and passed it the request object. From here I looped through the parameterNames, getting all the values and, since they were originally from select controls, putting all the data into vectors which were then saved as session variables. This seems to have worked nicely. Cheeeers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top