I have this problem in the code that I am looking at (done by someone who had been long gone).
The code reads the buffer that has the HttpServletRequest data. After the code reads the buffer here, I want to "reset" it so some other code in another component can read the same buffer again. Right now, when the buffer is read the second time by the other component, that code throws an IOException because there is no data returned (???) for the readLine (only my guess, don't have the other component's source code).
Here is the code I am looking at:
req is input defined as "HttpServletRequest req"
int theLen2 = 0;
String tempLine2;
theLen2 = req.getContentLength();
BufferedReader reqBody = new BufferedReader
(new InputStreamReader(req.getInputStream()));
String tempLine2;
tempLine2 = reqBody.readLine();
I put another BufferedReader and readLine in the code again just to see what happens when the buffer is read a second time, the reg.getContentLength() returns the correct length, but the reqBody.readLine returns nothing so tempLine2 is a null string.
I read from the Java book that a "mark" and "reset" can make the file available for a second read again. But I don't know how to mark it at the beginning of the "req".
And I could not find any other way to make the "req" available again.
Any ideas and/or suggestion will be greatly appreciated.
Lee