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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Any Way to Retrieve Request Body/Content Besides request.getReader()?

830391Jan 11 2011 — edited Jan 24 2011
We want to use a filter to do a message authentication check (HMAC-SHA1) for web-service calls. We want to use the request body as part of the message to hash/authenticate (ala Amazon Web Services). Our problem: we can retrieve the message body--via request.getReader() or request.getInputStream()--and use it to authenticate the incoming request. However, calls to chain.doFilter() or getRequestDispatcher().forward() fail with a "java.lang.IllegalStateException: getReader()|getInputStream() has already been called for this request" error. Attempts to copy the request to another object before calling getReader(), using a HttpServletRequestWrapper, closing or resetting the reader etc all result in the IllegalStateException error.
So: is there a way to retrieve the request body without using getReader()|getInputStream()? Or is there a way to reset the request/reader state so that the request can be reached from the filter? Or is there a better way to do HMAC processing in Java EE?
This post has been answered by tschodt on Jan 13 2011
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 21 2011
Added on Jan 11 2011
8 comments
4,943 views