• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Parameter Doubt?

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following exceprt is from the servlet specs,

"Data from the query string and the post body are aggregated into the request
parameter set. Query string data is presented before post body data. For example, if a request is made with a query string of a=hello and a post body of a=goodbye&a=world, the resulting parameter set would be ordered a=(hello, goodbye, world)."

Can anyone interpret that and elaborate on how the request line looks and how the form page for such a request might look like??

Thanks in advance!
[ March 05, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how a request line looks like ?
well...you can refer the first chapter of HFSJ.
it has all the things that you need !
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's mostly irrelevant. In POST requests, your form values get added to the body. This spec is saying that, if you also had values in the URL, then the URL parameters would be included in the abstracted parameter set.

To get this to occur, you would need an HTML form submit as a POST and your HTML form's action attribute would have to have a parameter added directly to its path. A developer should never do this, however. If the developer needs the extra parameter, it should be made a hidden input variable in the HTML form, in which case it would be added to the body with the rest of the parameters.
 
Saurabh Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This relates to getParameterValues method, the statement says that if you are sending a value for a parameter(say, xyz)in query string and you are also sending one or more values for same parameter(xyz) in post body, then the query-string value(s) will be ordered first, followed by the post-body parameter values. i.e. the array from getParameterValues("xyz") would first give you the query-string values and then values from post body.

But, as stated by Marc, this is highly unlikely that you would do a post request with query parameters.

Thanks and regards,
Saurabh
 
Sandeep Krish
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marc/Sauraubh

Could you please elaborate based on the follwoing sample code?

<form action="/myTarget?param1=value" method="post">
<input type="text" name="Param2">
<input type="text" name="Param3">

<input type="submit" name="Submit"
</form>
[ March 06, 2007: Message edited by: Sandeep Krish ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
why are you using buttons here ? They won't be submitted.
 
Sandeep Krish
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh that was a mistake Santou!! I corrected it
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not able to understand the conversation...What will be the answer to my post?? I want to know if we can have multiple values for a single parameter??
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jothi Shankar Kumar Sankararaj:
I'm not able to understand the conversation...What will be the answer to my post?? I want to know if we can have multiple values for a single parameter??


Why don't you try it out and report back to us on the result?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As of now, I don't have a system that has the necessary things involved for me to try. I'll probably try it once I have access to a system...may be after a week. In this time, if anyone could provide me a solution, that would be really helpful!
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a checkbox form that has three checkboxes with the same name "vehicle". If the form is submitted with all three checked, then you have "multiple values for a single parameter". Looking at the spec can you tell us how you get those three values back after the form is submitted?

<form>
I have a bike:
<input type="checkbox" name="vehicle" value="Bike" />
<br />
I have a car:
<input type="checkbox" name="vehicle" value="Car" />
<br />
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane" />
...
</form>
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spec says, the resulting parameter set would be ordered...does that mean the last value will be returned???
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Query string data is presented before post body data.
2. If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

The order of the post body data is not discussed in the spec, and I don't think it actually sorts anything.
I'm not sure it's actually specified. I've checked a few RFC about URL construction, but can't find anything relevant.
Maybe you can't rely on the order. Only that query string data comes before post body data.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright! Thanks Satou!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic