This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Request input stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request input stream" Watch "Request input stream" New topic
Author

Request input stream

yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Hi everyone,

I'm having a small issue trying to grab a parameter value from a request. I thought it would just as easy as doing request.getParameter("parameter"); but it isn't in this case.
The parameter I'm looking for is stored in the input stream, I've actually iterated through the request inputstream and found the value there, but it's not in the request parameters. To confirm that it's not in there, I've iterated through the request.getParameters() Enumerable.

The input control is a dropdown list on a jsp page. Every time the user changes the selection in that dropdown list the page executes a post back to retrieve the new data to display.

We use Spring security and other Spring features in what I'll call our "Front" web application. The web app is actually more of a multi-tier app when that specific page is reached, because every time the value gets changed in the dropdown list, we really intercept the request in our Front web app and transfer the request to another web farm to get the response object back, well formatted with the appropriate data. In some ways the "Front" web app is behaving like a proxy.

I tried to read the input stream to extract that value, but it messes up the request being proxied to the other web farm. It looks like the input stream cannot be opened anymore after that.

Anyone would have any idea on how to proceed on that one?

Thanks,
Yann
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

yann luppo wrote:I'm having a small issue trying to grab a parameter value from a request. I thought it would just as easy as doing request.getParameter("parameter"); but it isn't in this case.

Actually, it is that easy unless you've mucked around with the form's enctype (usually done to allow file uploading as a multi-part request).

You shouldn't have to screw around with the input stream yourself. Is there some aspect of this that you are leaving out?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Hi Bear,

Well I haven't worked on the jsp page myself so I can't say for sure what the encoding type is, but I will check now and let you know.

Yann.
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Bear Bibeault wrote:
yann luppo wrote:I'm having a small issue trying to grab a parameter value from a request. I thought it would just as easy as doing request.getParameter("parameter"); but it isn't in this case.

Actually, it is that easy unless you've mucked around with the form's enctype (usually done to allow file uploading as a multi-part request).

You shouldn't have to screw around with the input stream yourself. Is there some aspect of this that you are leaving out?


The request content type is:

"request.getContentType()"= "text/plain; charset=UTF-8"

Is that the correct value or should it be: "application/x-www-form-urlencoded" ?

Oh and if that helps any the request I'm looking at is actually a DWR call.

Thanks for your help.
Ashwin Pai
Ranch Hand

Joined: May 20, 2008
Posts: 90
Yes the content type is correct.. By the way the the list is single select (dropdown) and not multiselect .. correct?

Ashwin


The only way to make your dream come true is to wake up.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The enctype of the form, if specified, is of interest.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Hi Yann and all,
Just a silly suggestion. I did read that you read the InputStream, but, you have verified the parameter name is given for the name attribute of the control?
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Ashwin Pai wrote:Yes the content type is correct.. By the way the the list is single select (dropdown) and not multiselect .. correct?

Ashwin


That's correct it's single select.
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Bear Bibeault wrote:The enctype of the form, if specified, is of interest.


Silly question... but how do I figure out the enctype?
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Gamini Sirisena wrote:Hi Yann and all,
Just a silly suggestion. I did read that you read the InputStream, but, you have verified the parameter name is given for the name attribute of the control?


Well here is the control definition once rendered:



And using firebug I am able to see the post data, line 8 is my parameter defined like this:



Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
In the inputstream of the request or with some http request debugging tool in the webbrowser.
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Bauke Scholtz wrote:In the inputstream of the request or with some http request debugging tool in the webbrowser.


Here is the content of the http header according to Firebug:

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
With the inputstream of the request I mean the request body, not the request headers.
yann luppo
Greenhorn

Joined: Oct 29, 2008
Posts: 26
Bauke Scholtz wrote:With the inputstream of the request I mean the request body, not the request headers.


Is it possible that DWR actually modifies the encoding of the inpustream? I believe it serializes the parameters which seems to me like it's modifying to some extent the inputstream format. Any idea if that's true or not and if it is how to go about that?

Thanks,
Yann
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request input stream
 
Similar Threads
How to retain selected content after post on same page
populating one dropdown box depending on the value of other dropdown box
JSF, JSTL, Struts, Velocity - where the heck do I start?
Camel vs Spring Integration. Part 2.
Caching implementation strategy