Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Encoding issue on my jsp page

Reply
Thread Tools

Encoding issue on my jsp page

 
 
Live DVB
Guest
Posts: n/a
 
      04-27-2010
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
 
Reply With Quote
 
 
 
 
Live DVB
Guest
Posts: n/a
 
      04-27-2010
On Apr 27, 5:21*pm, Live DVB <(E-Mail Removed)> wrote:
> /cut


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.
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      04-28-2010
On 27-04-2010 11:21, Live DVB wrote:
> 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
 
Reply With Quote
 
Arne Vajhj
Guest
Posts: n/a
 
      04-28-2010
On 27-04-2010 16:49, Live DVB wrote:
> On Apr 27, 5:21 pm, Live DVB<(E-Mail Removed)> wrote:
>> /cut

>
> 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

 
Reply With Quote
 
Live DVB
Guest
Posts: n/a
 
      04-28-2010
On Apr 28, 2:46*am, Arne Vajhj <(E-Mail Removed)> wrote:
> 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).

 
Reply With Quote
 
Jukka Lahtinen
Guest
Posts: n/a
 
      04-28-2010
Live DVB <(E-Mail Removed)> writes:

> 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.

--
Jukka Lahtinen
 
Reply With Quote
 
Lars Enderin
Guest
Posts: n/a
 
      04-28-2010
Jukka Lahtinen wrote:
> Live DVB <(E-Mail Removed)> writes:
>
>> 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.
>

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

 
Reply With Quote
 
Jukka Lahtinen
Guest
Posts: n/a
 
      04-28-2010
Lars Enderin <(E-Mail Removed)> writes:
> Jukka Lahtinen wrote:
>> Live DVB <(E-Mail Removed)> writes:


>>> 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.


> 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.

--
Jukka Lahtinen
 
Reply With Quote
 
Jukka Lahtinen
Guest
Posts: n/a
 
      04-28-2010
bugbear <bugbear@trim_papermule.co.uk_trim> writes:

> 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.

--
Jukka Lahtinen
 
Reply With Quote
 
RedGrittyBrick
Guest
Posts: n/a
 
      04-28-2010
On 28/04/2010 09:06, bugbear wrote:
> Lars Enderin wrote:
>> Jukka Lahtinen wrote:
>>> Live DVB <(E-Mail Removed)> writes:
>>>
>>>> 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.
>>>

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

>
> 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?

--
RGB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
<%JSP:include page="hello.jsp" %> Shinya Koizumi Java 3 03-12-2006 11:34 PM
Default Charset Encoding in JSP page is ASCII Fritz Bayer Java 1 05-30-2005 06:01 PM
How to get the html output of a local JSP page from my Java code, or use a JSP as an HTML templates. DigitalUncle Java 0 11-02-2004 05:22 PM
jsp:include parameters changes the page encoding Eqbal Java 1 12-01-2003 04:39 PM



Advertisments