You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2009/05/04 22:12:16 UTC
Re: Browser shows source of .jsp file. Why?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David,
On 4/27/2009 10:11 AM, David Rush wrote:
> The controller servlet is using three
>
> rd = req.getRequestDispatcher("something.jsp");
> rd.include(req,resp);
>
> blocks (with essentially header, main content, and footer .jsp files)
> to assemble the final output page. Initially there was no
> req.setContentType() at all. Once I added
> req.setContentType("text/html") it appears to have resolved the
> problem.
You shouldn't have had to do this. What file is calling the includes? If
it's just a servlet, then you almost definitely have to provide a
Content-Type header, because the "include" files aren't going to (not
are they permitted to, according to the servlet spec). If it came from a
JSP, the JSP's default Content-Type is text/html, and something is wrong.
It should be noted that both Google Chrome and Mozilla Firefox are
behaving correctly: MSIE violates the HTTP specification which states
that the Content-Type sent by the server (text/plain in your case) may
not be overridden (S7.2.1: "If and only if the media type is not given
by a Content-Type field, the recipient MAY attempt to guess the media
type[...]"). It's only a (stupid) coincidence that your servlet works in
MSIE.
You may want to inspect other servlets for the same type of defect.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkn/TB8ACgkQ9CaO5/Lv0PB5LgCgwKkczCMW1pI5dMpPOGVMEKeQ
Ic4AnRz4fraMcHbMS40FpJPvkZMgLE7F
=zbb2
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org