tomcat-users mailing list archives

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

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, 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();


To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message