Hi all,
I want to build a logging filter that does not only log the user/method/url
but also the content of the request (i.e. for PUT requests).
I easily can extract the content of the request via getReader().
The problem is that I always get:
java.lang.IllegalStateException: getReader() has already been called for
this request
I already tried to create a RequestWrapper (see below) but the getReader()
method of my wrapper never gets called and I still get the above exception.
Unfortunately I don't have access to the source code of the called servlet.
Am I doing something wrong?
Does anybody have a possible reason/solution?
Any hint is much appreciated
Guido
chain.doFilter(new BodyWrapper((HttpServletRequest)request, body),
response);
// body is a String containing the body of the request
}
private class BodyWrapper extends HttpServletRequestWrapper {
private String body;
private BodyWrapper(HttpServletRequest req, String bo) {
super(req);
body = bo;
}
public BufferedReader getReader()
throws java.io.IOException {
System.out.println("BodyWrapper.getReader() called");
return new BufferedReader(new StringReader(body));
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html