| Author |
how to read the HttpRequest twice
|
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
Hello,
Is there a way to read a HttpServletRequest inputStream twice?
I have made a deep copy, but in so doing have gone to the end of the stream.
I want to use the apache fileupload code to look for request parameters in the inputStream. Using the apache fileupload requires the request itself to be used as a parameter, so I can't use the copy.
I value your response!
-ravi
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
What you are doing sounds like a bad idea (a deep copy? what for?) but the usual way to read an InputStream twice is to wrap it in a PushbackInputStream with a suitably large buffer size.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
Why aren't you just using one of the 3rd-party packages that handles this for you?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
Hello,
I am processing a multipart fileupload request.
The first step is to read one of the request parameters and validate it.
The next step is to write the entire request inputStream to disc.
I am using apache fileupload jar file to get the request parameter from the stream.
So you see I need two passes of the request inputstream to fulfill my requirements.
-ravi
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Ravi Danum wrote:The next step is to write the entire request inputStream to disc.
Why would you want to do that?
|
 |
Ravi Danum
Ranch Hand
Joined: Jan 13, 2009
Posts: 104
|
|
This is the requirement. The file must be in this format to be read by the rest of the system.
Thanks.
-ravi
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
I ask again, why aren't you using one of the popular libraries to handle the multi-part request?
|
 |
 |
|
|
subject: how to read the HttpRequest twice
|
|
|