Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ServletInputStream in = request.getInputStream() throws error

843841Mar 9 2004 — edited Mar 16 2004
Hi all,
I'm using a RequestDispatcher to forward a request to another servlet on the same server. It took a while
to get it running, and now I'm stuck on this line of code:
public void service(HttpServletRequest request, HttpServletResponse response) {
  ...
  ServletInputStream in = request.getInputStream();
  ...
}
The error looks like follows:
java.lang.IllegalStateException: Reader already obtained for this request.
at org.apache.tomcat.facade.HttpServletRequestFacade.getInputStream(HttpServletRequestFacade.java:190)
....

I've tried to find info on this topic all day, but to no avail. I'm not sure how to get around this problem.
Do I need to reset() the request and mark() it again? If so, where do I do it, in the calling service, or in the
called service? Is there perhaps another way of getting the Content of the request without an InputStream
or Reader? Do I need to set something up on tomcat itself?

Also,
request.getReader().ready
returns false.

B.T.W. I'm running tomcat 3.2.4 on a Windows box.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2004
Added on Mar 9 2004
5 comments
1,289 views