Why can't I wrap the ServletRequest when trying to capture JSP Output
Posted
by Patrick Cornelissen
on Stack Overflow
See other posts from Stack Overflow
or by Patrick Cornelissen
Published on 2010-04-12T08:49:30Z
Indexed on
2010/04/12
8:53 UTC
Read the original article
Hit count: 315
I am trying to dispatch in a servlet request handler to the JSP processor and capture the content of it.
I am providing wrapper instances for the ServletRequest and ServletResponse, they implement the corresponding HTTPServletRequest/-Response interfaces, so they should be drop-in replacements. All methods are currently passed to the original Servlet Request object (I am planning to modify some of them soon). Additionally I have introduced some new methods. (If you want to see the code: http://code.google.com/p/gloudy/source/browse/trunk/gloudyPortal/src/java/org/gloudy/gloudlet/impl/RenderResponseImpl.java)
The HttpServletResponse uses it's own output streams to capture the output.
When I try to call
request.getRequestDispatcher("/WEB-INF/views/test.jsp").include(request, response);
With my request and response wrappers the method returns and no content has been captured. When I tried to pass the original request object it worked! But that's not what I need in the long run...
request.getRequestDispatcher("/WEB-INF/views/test.jsp").include(request.getServletRequest(), response);
This works. getservletRequest() returns the original Request, given by the servlet container.
Does anyone know why this is not working with my wrappers?
© Stack Overflow or respective owner