Encoding issue on my jsp page

Discussion in 'Java' started by Live DVB, Apr 27, 2010.

  1. Live DVB

    Live DVB Guest

    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
     
    Live DVB, Apr 27, 2010
    #1
    1. Advertising

  2. Live DVB

    Live DVB Guest

    On Apr 27, 5:21 pm, Live DVB <> 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.
     
    Live DVB, Apr 27, 2010
    #2
    1. Advertising

  3. 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
     
    Arne Vajhøj, Apr 28, 2010
    #3
  4. Live DVB

    Arne Vajhøj Guest

    On 27-04-2010 16:49, Live DVB wrote:
    > On Apr 27, 5:21 pm, Live DVB<> 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
     
    Arne Vajhøj, Apr 28, 2010
    #4
  5. Live DVB

    Live DVB Guest

    On Apr 28, 2:46 am, Arne Vajhøj <> 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).
     
    Live DVB, Apr 28, 2010
    #5
  6. Live DVB <> 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
     
    Jukka Lahtinen, Apr 28, 2010
    #6
  7. Live DVB

    Lars Enderin Guest

    Jukka Lahtinen wrote:
    > Live DVB <> 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.
     
    Lars Enderin, Apr 28, 2010
    #7
  8. Lars Enderin <> writes:
    > Jukka Lahtinen wrote:
    >> Live DVB <> 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
     
    Jukka Lahtinen, Apr 28, 2010
    #8
  9. 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
     
    Jukka Lahtinen, Apr 28, 2010
    #9
  10. On 28/04/2010 09:06, bugbear wrote:
    > Lars Enderin wrote:
    >> Jukka Lahtinen wrote:
    >>> Live DVB <> 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
     
    RedGrittyBrick, Apr 28, 2010
    #10
  11. Jukka Lahtinen writes:
    > Lars Enderin <> writes:
    > > Jukka Lahtinen wrote:
    > >> 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


    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.
     
    Jussi Piitulainen, Apr 28, 2010
    #11
  12. Jussi Piitulainen <> writes:
    > Jukka Lahtinen writes:
    >> Lars Enderin <> writes:


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


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

    --
    Jukka Lahtinen
     
    Jukka Lahtinen, Apr 28, 2010
    #12
  13. Live DVB

    Arne Vajhøj Guest

    On 28-04-2010 03:23, Jukka Lahtinen wrote:
    > Live DVB<> 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.


    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
     
    Arne Vajhøj, Apr 29, 2010
    #13
  14. Live DVB

    Arne Vajhøj Guest

    On 28-04-2010 04:06, bugbear wrote:
    > Lars Enderin wrote:
    >> Jukka Lahtinen wrote:
    >>> Live DVB <> 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?


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

    :)

    Arne
     
    Arne Vajhøj, Apr 29, 2010
    #14
  15. Live DVB

    Arne Vajhøj Guest

    On 28-04-2010 06:09, Jukka Lahtinen wrote:
    > 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


    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
     
    Arne Vajhøj, Apr 29, 2010
    #15
  16. Live DVB

    Arne Vajhøj Guest

    On 28-04-2010 06:06, Jukka Lahtinen wrote:
    > Lars Enderin<> writes:
    >> Jukka Lahtinen wrote:
    >>> Live DVB<> 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?)


    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
     
    Arne Vajhøj, Apr 29, 2010
    #16
  17. Live DVB

    Arne Vajhøj Guest

    On 28-04-2010 03:17, Live DVB wrote:
    > On Apr 28, 2:46 am, Arne Vajhøj<> 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).


    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
     
    Arne Vajhøj, Apr 29, 2010
    #17
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eqbal
    Replies:
    1
    Views:
    1,216
    John C. Bollinger
    Dec 1, 2003
  2. DigitalUncle
    Replies:
    0
    Views:
    981
    DigitalUncle
    Nov 2, 2004
  3. Fritz Bayer
    Replies:
    1
    Views:
    4,334
    Wibble
    May 30, 2005
  4. Shinya Koizumi

    <%JSP:include page="hello.jsp" %>

    Shinya Koizumi, Mar 9, 2006, in forum: Java
    Replies:
    3
    Views:
    9,832
    Raymond DeCampo
    Mar 12, 2006
  5. Replies:
    0
    Views:
    4,499
Loading...

Share This Page