You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Laukó Péter <pl...@freemail.hu> on 2002/08/23 00:34:04 UTC

character encoding problem

Hi List,
I'm having problems about character encoding (latin2).
I receive string data from PostgreSQL tables and when I put them on my jsp pages some characters are converted to "?"-s. It happens with letters "ő" and "ű".
The data in the db is correct.
I set the character encoding in the pages by:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
and all characters I write _dirctly_ in the pages are displayed correctly.
I set the locale in the tomcat startup script by "export LANG=hu_HU" and checking Locale.getDefault() gives the correct answer (huHU), but has no effect.
The only solution I have found so far is this:
<%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
This results in the correct display but means I have to escape _all_ outputs by hand.
There must be an easier solution. Please help!
thanks in advance, Peter



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
Ryszard Lach wrote:

> On Fri, Aug 23, 2002 at 12:34:04AM +0200, Laukó Péter wrote:


> Funny, it is exactly the same solution that we've found, and with JSP it works
> only with older jdbc drivers. I would appreciate too if anyoune let know
> how to deal with it 'more elegan'.

Lord knows I've had my share of troubles with this combo. Finally I found the 
way to make it all work.

PostgreSQL - the particular DB was Unicode encoded.
JDBC - normal connection string
JSP - just normal statements, with
       <@ page contentType="text/html; charset=win-1250">

Believe it or not, CP1250 works, at least on Tru64 UNIX JRE.

Formally, the DB should work even if LATIN-2 encoded, but I've had odd problems, 
which went away the moment I switched to Unicode.

Nix.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Ryszard Lach <rl...@id.pl>.
On Fri, Aug 23, 2002 at 12:34:04AM +0200, Laukó Péter wrote:
> 
> Hi List,
> I'm having problems about character encoding (latin2).
> I receive string data from PostgreSQL tables and when I put them on my jsp pages some characters are converted to "?"-s. It happens with letters "ő" and "ű".
> The data in the db is correct.
> I set the character encoding in the pages by:
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
> and all characters I write _dirctly_ in the pages are displayed correctly.
> I set the locale in the tomcat startup script by "export LANG=hu_HU" and checking Locale.getDefault() gives the correct answer (huHU), but has no effect.
> The only solution I have found so far is this:
> <%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
> This results in the correct display but means I have to escape _all_ outputs by hand.
> There must be an easier solution. Please help!
> thanks in advance, Peter

Funny, it is exactly the same solution that we've found, and with JSP it works
only with older jdbc drivers. I would appreciate too if anyoune let know
how to deal with it 'more elegan'.

Richard.

-- 
"First they ignore you. Then they laugh at you. Then they
fight you. Then you win." - Mohandas Gandhi.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Laukó Péter <pl...@freemail.hu>.
Wooow!
It works!!!
Thank you very very much.


Bill Barker <re...@verizon.net> írta:

> For Tomcat 4.x.x you can set:
> <%@page content-type="text/html; charset=ISO-8859-2" %>
> <%@page pageEncoding="ISO-8859-2" %>
> 
> The first one sets the charset for the writer, the second one tells the JSP
> compiler which charset it should use for the reader when it is compiling the
> page.
> 
> "Laukó Péter" <pl...@freemail.hu> wrote in message
> news:freemail.20020724010642.62112@fm4.freemail.hu...
> 
> Hello,
> yes I use JSP. If I put any of these lines in the page the strings from the
> db become correct, but the characters written directly in the page go wrong.
> (just the opposite situation as before.) What's the way to get them work
> together???
> Thanks for your answer, Peter
> 
> 
> 
> Bill Barker <re...@verizon.net> írta:
> 
> > I'm assuming that this is happing within a JSP page.  In which case, you
> > need to set:
> > <%@page content-type="text/html; charset=ISO-8859-2" %>
> > response.setContentType("text/html; charset=ISO-8859-2");
> >
> > The problem is the the Writer's charset is determined by one of the above,
> > and will default to ISO-8859-1 (as per the spec) if not specified.
> >
> > "Laukó Péter" <pl...@freemail.hu> wrote in message
> > news:freemail.20020723003404.85087@fm3.freemail.hu...
> >
> > Hi List,
> > I'm having problems about character encoding (latin2).
> > I receive string data from PostgreSQL tables and when I put them on my jsp
> > pages some characters are converted to "?"-s. It happens with letters "ő"
> > and "ű".
> > The data in the db is correct.
> > I set the character encoding in the pages by:
> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
> > and all characters I write _dirctly_ in the pages are displayed correctly.
> > I set the locale in the tomcat startup script by "export LANG=hu_HU" and
> > checking Locale.getDefault() gives the correct answer (huHU), but has no
> > effect.
> > The only solution I have found so far is this:
> > <%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
> > This results in the correct display but means I have to escape _all_
> outputs
> > by hand.
> > There must be an easier solution. Please help!
> > thanks in advance, Peter
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> >
> >
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
> 





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Bill Barker <re...@verizon.net>.
For Tomcat 4.x.x you can set:
<%@page content-type="text/html; charset=ISO-8859-2" %>
<%@page pageEncoding="ISO-8859-2" %>

The first one sets the charset for the writer, the second one tells the JSP
compiler which charset it should use for the reader when it is compiling the
page.

"Lauk� P�ter" <pl...@freemail.hu> wrote in message
news:freemail.20020724010642.62112@fm4.freemail.hu...

Hello,
yes I use JSP. If I put any of these lines in the page the strings from the
db become correct, but the characters written directly in the page go wrong.
(just the opposite situation as before.) What's the way to get them work
together???
Thanks for your answer, Peter



Bill Barker <re...@verizon.net> �rta:

> I'm assuming that this is happing within a JSP page.  In which case, you
> need to set:
> <%@page content-type="text/html; charset=ISO-8859-2" %>
> response.setContentType("text/html; charset=ISO-8859-2");
>
> The problem is the the Writer's charset is determined by one of the above,
> and will default to ISO-8859-1 (as per the spec) if not specified.
>
> "Lauk� P�ter" <pl...@freemail.hu> wrote in message
> news:freemail.20020723003404.85087@fm3.freemail.hu...
>
> Hi List,
> I'm having problems about character encoding (latin2).
> I receive string data from PostgreSQL tables and when I put them on my jsp
> pages some characters are converted to "?"-s. It happens with letters "�"
> and "�".
> The data in the db is correct.
> I set the character encoding in the pages by:
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
> and all characters I write _dirctly_ in the pages are displayed correctly.
> I set the locale in the tomcat startup script by "export LANG=hu_HU" and
> checking Locale.getDefault() gives the correct answer (huHU), but has no
> effect.
> The only solution I have found so far is this:
> <%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
> This results in the correct display but means I have to escape _all_
outputs
> by hand.
> There must be an easier solution. Please help!
> thanks in advance, Peter
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>
>





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Ryszard Lach <rl...@id.pl>.
On Thu, Aug 22, 2002 at 09:34:22PM -0700, Bill Barker wrote:
> I'm assuming that this is happing within a JSP page.  In which case, you
> need to set:
> <%@page content-type="text/html; charset=ISO-8859-2" %>
> response.setContentType("text/html; charset=ISO-8859-2");
> 
> The problem is the the Writer's charset is determined by one of the above,

Not quite. I've always set <@page....> . Indeed, it is needed to
correctly display non-US characters, but doesn't help with JDBC
connection.

Richard.

-- 
"First they ignore you. Then they laugh at you. Then they
fight you. Then you win." - Mohandas Gandhi.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Laukó Péter <pl...@freemail.hu>.
Hello,
yes I use JSP. If I put any of these lines in the page the strings from the db become correct, but the characters written directly in the page go wrong. (just the opposite situation as before.) What's the way to get them work together???
Thanks for your answer, Peter



Bill Barker <re...@verizon.net> írta:

> I'm assuming that this is happing within a JSP page.  In which case, you
> need to set:
> <%@page content-type="text/html; charset=ISO-8859-2" %>
> response.setContentType("text/html; charset=ISO-8859-2");
> 
> The problem is the the Writer's charset is determined by one of the above,
> and will default to ISO-8859-1 (as per the spec) if not specified.
> 
> "Laukó Péter" <pl...@freemail.hu> wrote in message
> news:freemail.20020723003404.85087@fm3.freemail.hu...
> 
> Hi List,
> I'm having problems about character encoding (latin2).
> I receive string data from PostgreSQL tables and when I put them on my jsp
> pages some characters are converted to "?"-s. It happens with letters "ő"
> and "ű".
> The data in the db is correct.
> I set the character encoding in the pages by:
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
> and all characters I write _dirctly_ in the pages are displayed correctly.
> I set the locale in the tomcat startup script by "export LANG=hu_HU" and
> checking Locale.getDefault() gives the correct answer (huHU), but has no
> effect.
> The only solution I have found so far is this:
> <%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
> This results in the correct display but means I have to escape _all_ outputs
> by hand.
> There must be an easier solution. Please help!
> thanks in advance, Peter
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
> 





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: character encoding problem

Posted by Bill Barker <re...@verizon.net>.
I'm assuming that this is happing within a JSP page.  In which case, you
need to set:
<%@page content-type="text/html; charset=ISO-8859-2" %>
response.setContentType("text/html; charset=ISO-8859-2");

The problem is the the Writer's charset is determined by one of the above,
and will default to ISO-8859-1 (as per the spec) if not specified.

"Lauk� P�ter" <pl...@freemail.hu> wrote in message
news:freemail.20020723003404.85087@fm3.freemail.hu...

Hi List,
I'm having problems about character encoding (latin2).
I receive string data from PostgreSQL tables and when I put them on my jsp
pages some characters are converted to "?"-s. It happens with letters "�"
and "�".
The data in the db is correct.
I set the character encoding in the pages by:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">
and all characters I write _dirctly_ in the pages are displayed correctly.
I set the locale in the tomcat startup script by "export LANG=hu_HU" and
checking Locale.getDefault() gives the correct answer (huHU), but has no
effect.
The only solution I have found so far is this:
<%=new String( journal.getName().getBytes("ISO-8859-2"), "ISO-8859-1")%>
This results in the correct display but means I have to escape _all_ outputs
by hand.
There must be an easier solution. Please help!
thanks in advance, Peter





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: from port 8080 to port 80

Posted by neal <ne...@yahoo.com>.
Further wierdness....in addition to it still listening on port 8080 ... the
webmodule I just installed is apparently non-existant ... that according to
my browsing session to view the web app.  It would seem that perhaps there
really IS another instance running or something ... but we just installed
the first ever install of Tomcat and did so without the NT service...it
seems like an impossibility that a duplicate would be running ... but the
symptoms would suggest that to be the case.   I'm stuck.  Any thoughts?


Thanks.
Neal


-----Original Message-----
From: Keith Wannamaker [mailto:Keith@Wannamaker.org]
Sent: Thursday, August 22, 2002 5:58 PM
To: Tomcat Users List
Subject: RE: from port 8080 to port 80


Sounds like the instance of tomcat which is running is not using the
configuration file you are editing, or you've got another instance of tomcat
running on 8080.  You didn't specify if the port 80 was being listened to.
After you have ruled out other instances, grep the config file for 80 and
double check you don't have another connector configured.

Keith

| -----Original Message-----
| From: neal [mailto:nealcabage@yahoo.com]
| Sent: Thursday, August 22, 2002 6:45 PM
| To: Tomcat Users List
| Subject: from port 8080 to port 80
|
|
| I changed Tomcat from listening on port 8080 to port 80 in the
| conf/server.xml file.  But its still listening on port 8080.  Saved file,
| restarted tomcat and it still didn't work. Restarted computer...still
didn't
| work.  ANy thoughts? I did this on a different computer and it worked
fine.
|
|

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: from port 8080 to port 80

Posted by Keith Wannamaker <Ke...@Wannamaker.org>.
I'm just saying what you're describing sounds like another instance.
Check the service manager, TC should be labeled.  Or, just look at
the processes in the task list.

Keith

| -----Original Message-----
| From: neal [mailto:nealcabage@yahoo.com]
| Sent: Thursday, August 22, 2002 7:11 PM
| To: Tomcat Users List
| Subject: RE: from port 8080 to port 80 
| 
| 
| Well, it was a fresh install so I don't think it was possible that (a) we
| would have a second copy or (b) that we'd have addtional nodes specifying
| 8080 in the server.xml file...in fact just confirmed .... no extra nodes.
| And, we installed without the NT service ... so I don't I don't think it
| could be running.  On the chance that it is the NT sevrice causing grief
| though ... do you know the name the service runs under on Windows?
| 
| Thanks.
| Neal
| 
| 
| -----Original Message-----
| From: Keith Wannamaker [mailto:Keith@Wannamaker.org]
| Sent: Thursday, August 22, 2002 5:58 PM
| To: Tomcat Users List
| Subject: RE: from port 8080 to port 80
| 
| 
| Sounds like the instance of tomcat which is running is not using the
| configuration file you are editing, or you've got another instance of tomcat
| running on 8080.  You didn't specify if the port 80 was being listened to.
| After you have ruled out other instances, grep the config file for 80 and
| double check you don't have another connector configured.
| 
| Keith
| 
| | -----Original Message-----
| | From: neal [mailto:nealcabage@yahoo.com]
| | Sent: Thursday, August 22, 2002 6:45 PM
| | To: Tomcat Users List
| | Subject: from port 8080 to port 80
| |
| |
| | I changed Tomcat from listening on port 8080 to port 80 in the
| | conf/server.xml file.  But its still listening on port 8080.  Saved file,
| | restarted tomcat and it still didn't work. Restarted computer...still
| didn't
| | work.  ANy thoughts? I did this on a different computer and it worked
| fine.
| |
| |
| 
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@jakarta.apache.org>
| 
| 
| --
| To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
| For additional commands, e-mail: <ma...@jakarta.apache.org>
| 
| 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: from port 8080 to port 80

Posted by neal <ne...@yahoo.com>.
Well, it was a fresh install so I don't think it was possible that (a) we
would have a second copy or (b) that we'd have addtional nodes specifying
8080 in the server.xml file...in fact just confirmed .... no extra nodes.
And, we installed without the NT service ... so I don't I don't think it
could be running.  On the chance that it is the NT sevrice causing grief
though ... do you know the name the service runs under on Windows?

Thanks.
Neal


-----Original Message-----
From: Keith Wannamaker [mailto:Keith@Wannamaker.org]
Sent: Thursday, August 22, 2002 5:58 PM
To: Tomcat Users List
Subject: RE: from port 8080 to port 80


Sounds like the instance of tomcat which is running is not using the
configuration file you are editing, or you've got another instance of tomcat
running on 8080.  You didn't specify if the port 80 was being listened to.
After you have ruled out other instances, grep the config file for 80 and
double check you don't have another connector configured.

Keith

| -----Original Message-----
| From: neal [mailto:nealcabage@yahoo.com]
| Sent: Thursday, August 22, 2002 6:45 PM
| To: Tomcat Users List
| Subject: from port 8080 to port 80
|
|
| I changed Tomcat from listening on port 8080 to port 80 in the
| conf/server.xml file.  But its still listening on port 8080.  Saved file,
| restarted tomcat and it still didn't work. Restarted computer...still
didn't
| work.  ANy thoughts? I did this on a different computer and it worked
fine.
|
|

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: from port 8080 to port 80

Posted by Keith Wannamaker <Ke...@Wannamaker.org>.
Sounds like the instance of tomcat which is running is not using the
configuration file you are editing, or you've got another instance of tomcat
running on 8080.  You didn't specify if the port 80 was being listened to.
After you have ruled out other instances, grep the config file for 80 and
double check you don't have another connector configured.

Keith

| -----Original Message-----
| From: neal [mailto:nealcabage@yahoo.com]
| Sent: Thursday, August 22, 2002 6:45 PM
| To: Tomcat Users List
| Subject: from port 8080 to port 80 
| 
| 
| I changed Tomcat from listening on port 8080 to port 80 in the
| conf/server.xml file.  But its still listening on port 8080.  Saved file,
| restarted tomcat and it still didn't work. Restarted computer...still didn't
| work.  ANy thoughts? I did this on a different computer and it worked fine.
| 
| 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


from port 8080 to port 80

Posted by neal <ne...@yahoo.com>.
I changed Tomcat from listening on port 8080 to port 80 in the
conf/server.xml file.  But its still listening on port 8080.  Saved file,
restarted tomcat and it still didn't work. Restarted computer...still didn't
work.  ANy thoughts? I did this on a different computer and it worked fine.

Version 4.0.4 on Windows XP home.  JDK 1.4

Thanks.
Neal



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>