tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Spath <msp...@arcor.de>
Subject Re: changing the default character encoding
Date Mon, 25 Feb 2002 05:30:11 GMT
Richard,

Richard Sand wrote:

> Hi all-  Does anyone know how to specify the default encoding for the JVM in
> a linux environment?
> 
> I'm having difficulty with my servlets because the JVM on my system (sun
> jdk1.3.1 on linux) is defaulting to us-ascii encoding instead of using
> iso-8859-1.  I know I can override the encoding inside my code, but
> according to the package description for java.lang, the JVM determines the
> default encoding by looking at the OS.  I tried setting both LANG and
> LC_CTYPE in my shell before launching catalina.sh, but I still couldn't get
> the servlets to not default to US-ASCII.


i guess you want to set the encoding of your servlets response.

you can do this, calling the setContentType() method of the 
(Http)ServletResponse object - before getting a Writer or Stream.

...
public void doGet(HttpServletRequest request, HttpServletResponse response) {

     response.setContentType("text/html; charset=ISO-8859-1");

     PrintWriter blabla = response.getWriter();
     ....
}

regards,
Markus





--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message