Hi folks.
I was wondering. I have an application where I would like to
dynamically set the Content-Type of the output.
The flow of the application is pretty simple... The entry point is a
Servlet, which uses a RequestDispatcher to "forward()" or "include()"
the request on to a JSP.
I've found that if I use "RequestDispatcher.include()" I can set the
content type in the calling servlet by doing "response.setContentType(
"text/whatever" )".
However, if I use "RequestDispatcher.forward()", the
"response.setContentType("text/whatever")" is ignored, and the content
type is always set to "text/html".
I know that it's possible to use the JSP "<%@page
contentType="text/whatever">", however you can't dynamically set that
based on some criteria.
So, my first (somewhat long winded) question is: Is it a bug or a
feature that the "response.setContentType()" is ignored when using
RequestDispatcher.forward()?
Also, does anyone know of a way to get around this problem?
If you're asking "Why don't you just use RequestDispatcher.include()"?
The answer is that there's another bug with RequestDispatcher.include()
where the session information is always lost.
Thanks.
...alex...
|