Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: setContentType() vs. <meta http-equiv='Content-Type' ...>

Bill Barker

2004-01-16

Replies:

Actually, you don't get an exception if you don't call setContentType: You
just get you page encoded and sent to the browser in iso-latin-1 (as per the
spec).

Yoav is correct that Tomcat (and probably most servlet containers) simply
consider meta tags as just some text to push to the browser. The problem is
that (assuming the browser can read the tag at all), Tomcat is sending in
iso-latin-1, not what is in your meta tag.

"Shapira, Yoav" <Yoav.Shapira@(protected)
news:9C5166762F311146951505C6790A9CF8013DFAE4@(protected)...

Howdy,

>Does Tomcat see any difference in a servlet that calls setContentType()
>before generating a page for output versus not calling setContentType()
but
>including an HTML <meta http-equiv='Content-Type' ...> tag in the
generated
>page?

You might want to define "Does Tomcat see any difference" more
precisely. The servlet API does make a difference, as setContentType
(or setCharacterEncoding, or setLocale) must be called on a request
before calling getWriter(). Otherwise you get an exception. So yeah,
there's a difference.

Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged. This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else. If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender. Thank you.




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.