Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

RequestDispatcher and pageEncoding question...

Timothy Stone

2004-04-15


J2EE List,

A servlet I am debugging and trying to understand sets the response's
contentType as follows:

response.setContentType( "text/html;charset=UTF-8" );

Shortly following the following forward:

request.getRequestDispatcher( jspPage ).forward( request, response );
response.getWriter().flush();

The forward gets the response with the contentType set, but the forward
resource seems to reset the contentType to
'text/html;charset=ISO-8859-1'; the default.

The JSP in the forward does not set a pageEncoding attribute in the
page directive, so I'm pointing fingers at this for the moment. Can
someone elaborate on what is going on behind the scenes of the
requestDispatcher call that would be reseting the response's
contentType? The documentation implies that the "...uncommitted output
in the response buffer is automatically cleared before the forward."
Okay, does this clear/reset the headers too? I know that one cannot set
new headers in a call to RequestDispatcher's include().

An expert/guru opinion on this would be very much appreciated.

Finally, I'm seeing this behavior in Tomcat 4.1.29 on
Windows/Linux/Macintosh.

Many thanks in advance,
Tim

===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".
©2008 junlu.com - Jax Systems, LLC, U.S.A.