Encoding issue on my jsp page

L

Live DVB

I'm having this encoding issue that drives me nuts.

Basically there's a form:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
(...)
head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
(...)
<h1> Header: Å¡ ć Ä‘ Ä <h1>
<% out.println("Print: " + request.getParameter("txtArea")); %>
<form method="post" action="newjsp.jsp">
<textarea name="txtArea">Å¡ ć Ä‘ Ä</textarea>
<input type="submit" value="Submit"/>
</form>
--
1) When i press submit it prints out " š ć đ Ġ"
2) If I change encoding from UTF-8 to Windows-1250, I get lots of
question marks: ? ? ? ?
3) If i change encoding from UTF-8 to iso-8859-1, the data prints ok,
but <h1> Header: Å¡ ć Ä‘ Ä <h1> becomes <h1> Header: ? ? ? ? <h1>
4) If I change method to GET with utf-8 encoding everything's fine

p.s. "Å¡ ć Ä‘ Ä" are croatian letters
 
L

Live DVB


Well in the end, after few more hours of work I changed URIEncoding to
"windows-1250" at my server.xml, also changed all utf-8 to
windows-1250. I then changed the letters with their ascii(hex?)
counterparts č etc. I guess that's it.
 
A

Arne Vajhøj

I'm having this encoding issue that drives me nuts.

Basically there's a form:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
(...)
head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
(...)
<h1> Header: Å¡ ć Ä‘ Ä<h1>
<% out.println("Print: " + request.getParameter("txtArea")); %>
<form method="post" action="newjsp.jsp">
<textarea name="txtArea">Å¡ ć Ä‘ Ä</textarea>
<input type="submit" value="Submit"/>
</form>
--
1) When i press submit it prints out " š ć đ Ġ"
2) If I change encoding from UTF-8 to Windows-1250, I get lots of
question marks: ? ? ? ?
3) If i change encoding from UTF-8 to iso-8859-1, the data prints ok,
but<h1> Header: Å¡ ć Ä‘ Ä<h1> becomes<h1> Header: ? ? ? ?<h1>
4) If I change method to GET with utf-8 encoding everything's fine

p.s. "Å¡ ć Ä‘ Ä" are croatian letters

If you are consistent (labeling and actual content match), then
all encodings supported by the browser and server should work
fine.

To get it working with ISO-8859-1 / Windows-1250 I think you
need to save the file in that encoding instead if the UTF-8 it
apparently is saved in.

The first problem indicates is a bit more tricky. Somewhere
some UTF-8 is being interpreted as ISO-8859-1 / Windows-1250.
Default charset in Java maybe.

Arne
 
A

Arne Vajhøj

Well in the end, after few more hours of work I changed URIEncoding to
"windows-1250" at my server.xml, also changed all utf-8 to
windows-1250.

That seems all fine.
I then changed the letters with their ascii(hex?)
counterpartsč etc. I guess that's it.

That is a poor hack.

You could most likely have fixed the last problem by
just saving the file in windows-1250.

Arne
 
L

Live DVB

That is a poor hack.

You could most likely have fixed the last problem by
just saving the file in windows-1250.

Well you're correct of course, it's not really a good solution,
however, changing the encoding on project properties didn't solve the
problem. I'm not sure of some other way to do this (I'm using
Netbeans).
 
J

Jukka Lahtinen

Live DVB said:
Well in the end, after few more hours of work I changed URIEncoding to
"windows-1250" at my server.xml, also changed all utf-8 to
windows-1250. I then changed the letters with their ascii(hex?)

BAD change. You should use ISO-8859-1 instead, it's a universal standard
unlike windows-anything.
 
L

Lars Enderin

Jukka said:
BAD change. You should use ISO-8859-1 instead, it's a universal standard
unlike windows-anything.
ISO-8859-1 doesn't work for all European languages. There are other
ISO-8859-? variants.
 
J

Jukka Lahtinen

ISO-8859-1 doesn't work for all European languages. There are other
ISO-8859-? variants.

Sorry, I forgot that, always using iso-8859-1 myself when writing
Finnish. (Does windows-1250 support some languages not supported in
iso-8859-1?)

Anyway, my point was that windows-1250 is platform-specific, meant only
for M$ systems, while iso standards are platform-independent and
universally standardized.
 
J

Jukka Lahtinen

bugbear said:
I'm confused. In 2010, coding a website under Java, why
would anyone use anything other than utf-8, giving
full Unicode support?

To avoid multibyte encoding. It makes file sizes and string lengths
confusing and there are editors and other software that don't support
it.
 
R

RedGrittyBrick

I'm confused. In 2010, coding a website under Java, why
would anyone use anything other than utf-8, giving
full Unicode support?

I think the OP tried that and couldn't get it to work.

Surely there is a UTF-8 solution?
 
J

Jussi Piitulainen

Jukka said:
Sorry, I forgot that, always using iso-8859-1 myself when writing
Finnish. (Does windows-1250 support some languages not supported in

A man page, however, notes this about iso-8859-1: "it lacks the EURO
symbol and does not fully cover __Finnish__ and French." Emphasis is
mine. I'm not sure what all is missing for Finnish. S-with-caron is
one, or two, and maybe z-with-caron is counted as needed for
Finnish. Those are rare, but the euro symbol is rather important.

That's why we have iso-8859-15 aka latin-9, one of those less-used
iso-8859 variants. And, of course, UTF-8.
Anyway, my point was that windows-1250 is platform-specific, meant
only for M$ systems, while iso standards are platform-independent
and universally standardized.

Yes.
 
J

Jukka Lahtinen

A man page, however, notes this about iso-8859-1: "it lacks the EURO
symbol and does not fully cover __Finnish__ and French." Emphasis is

Yeah, the euro symbol hadn't yet been invented when iso-8859-1 was
standardized. Wherever it is really needed, iso-8859-15 should be used
instead. But I very rarely use it, so I use iso-8859-1 because is more
widely supported, and spell euro or use 'e'.
mine. I'm not sure what all is missing for Finnish. S-with-caron is
one, or two, and maybe z-with-caron is counted as needed for
Finnish. Those are rare, but the euro symbol is rather important.

I don't consider them Finnish characters, because they are really not
needed in Finnish. The two words that begin with s-caron can as well
be written with sh (and mostly are), and I can't think of any Finnish
word with z-caron.
 
A

Arne Vajhøj

BAD change. You should use ISO-8859-1 instead, it's a universal standard
unlike windows-anything.

Being a universal standard does not help him much when the standard
does not contain the characters he need.

He needs ISO-8859-2.

And BTW Windows-1250 is "close" to IS0-8859-2 (there are
more important difference than between Windows-1252 and
ISO-8859-1 though !).

Arne
 
A

Arne Vajhøj

I'm confused. In 2010, coding a website under Java, why
would anyone use anything other than utf-8, giving
full Unicode support?

Nostalgia like Cobol, punched cards, hardcopy terminals etc..

:)

Arne
 
A

Arne Vajhøj

To avoid multibyte encoding. It makes file sizes and string lengths
confusing

It should not have any significance for the typical web app.
and there are editors and other software that don't support
it.

Time to upgrade or change software.

Arne
 
A

Arne Vajhøj

Sorry, I forgot that, always using iso-8859-1 myself when writing
Finnish. (Does windows-1250 support some languages not supported in
iso-8859-1?)

Yes.

Windows-1252 is more like ISO-8859-2.
Anyway, my point was that windows-1250 is platform-specific, meant only
for M$ systems, while iso standards are platform-independent and
universally standardized.

The differences between Windows and ISO are practically zero for
western european, but noticeable for eastern/central european.

Arne
 
A

Arne Vajhøj

Well you're correct of course, it's not really a good solution,
however, changing the encoding on project properties didn't solve the
problem. I'm not sure of some other way to do this (I'm using
Netbeans).

I don't think changing project properties will update the
content of files in the project. But since I does not
use NB then I can not be sure.

But many editors have the ability to "Save As" in a given
encoding.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top