aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubt regarding request parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt regarding request parameters" Watch "doubt regarding request parameters" New topic
Author

doubt regarding request parameters

Nitin Vashishtha
Ranch Hand

Joined: Mar 26, 2008
Posts: 31
Hello Ranchers,

I have a doubt in Mikalai Zaikin notes regarding the request parameters.
Below is the statement from the notes:

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, and a post body of a=goodbye&a=world, the resulting parameter set would be ordered a=(hello, goodbye, world).

my doubt is:

How is it possible to send the data from query string (means Get request) and in body (means POST request) at the same time?

any help will be appeciated on this.


Nitin
SCJP 91%, TOFAG 9 certified 89%
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Nitin,

I'm sure that it's only possible to use either HTTP GET method or POST method but you just cannot use both at the same time as you already said.

But I think it's possible to make a POST request with POST data and at the same time give additional parameters in the URL you're using to submit your form data to. This is the only possibility I could imagine although I've never tried this. And usually you decide to use POST or GET depending on the the kind of request (idempotent request should use GET, others POST).

And I'm unsure about the behavior of the servlet implementation, too. I don't even know if GET parameters are honored if you use the POST method. Hopefully someone knows in more detail...

Marco
Nitin Vashishtha
Ranch Hand

Joined: Mar 26, 2008
Posts: 31
Thanks for your reply Macro.
Originally posted by Marco Ehrentreich:


But I think it's possible to make a POST request with POST data and at the same time give additional parameters in the URL you're using to submit your form data to.



This statement theoritically looks fine,but how can we practically send a POST request and append some query string to the URL at the same time?
because we can append query string either by appending it to the URL directly in the browser (in which case the request will be GET only) or in any href location on our HTML or JSP page with the URL already appended by the query string,(and in this case again it will be a GET request only) and if we send a POST request then I dont see any method to append explicitly the query string with the request.

Could Anybody else please share his/her knowledge on this?
Devasani Naresh
Greenhorn

Joined: Sep 20, 2007
Posts: 18
I think, if we modify the Request parameter (may be by using Filters), This scenario might come.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
It's possible to have an URL that has parameters in the action attribute of a form that uses POST.

Note that there is no ordering of parameters, though (which you mentioned in the first post). Any ordering you perceive there to be is accidental, and may change from between browsers or between servers.


Ping & DNS - my free Android networking tools app
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi,

you can give an URL with parameters as an action for your form I'd say... But as I already said this wouldn't be a real GET+POST request anyway because it's of course not possible to use two different HTTP methods like GET and POST in one real request.

You could additionally modify your request data using intercepting filters like Devasani said. Anyway in your servlet all parameters are treated equal and can be accessed using getParameter() (besides reading and parsing the whole body) so there has to be something happening before which might like a filter.

Or perhaps it's simply an error or an inaccuracy in the book!

Marco
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,



Is the valid post request and give the expected result. I thing the GET request is using the Query String mechanism to pass the data to server, but Query String is not restricted to GET request, You can use it with POST method also though it is displayed in browser window.

Thanks
[ April 07, 2008: Message edited by: Narendra Dhande ]

Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Nitin Vashishtha
Ranch Hand

Joined: Mar 26, 2008
Posts: 31
Thank you everyone.
Your help is highly appreciated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt regarding request parameters