struts validator question marks in messages

Discussion in 'Java' started by Elhanan, Dec 7, 2005.

  1. Elhanan

    Elhanan Guest

    hi..

    i've written a small struts validator sample,

    but i type in the resources file anything in hebrew , it apprears in
    the validator messages as question marks.
     
    Elhanan, Dec 7, 2005
    #1
    1. Advertising

  2. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > hi..
    >
    > i've written a small struts validator sample,
    >
    > but i type in the resources file anything in hebrew , it apprears in
    > the validator messages as question marks.


    You have an encoding problem somewhere. Java fully supports unicode, and
    I think when you're working with Unicode, it's generally easiest to use
    UTF-8 or UTF-16. Make sure whatever configuration files you're working with
    are encoded in a encoding that your program can understand (e.g. UTF-16),
    and make sure whatever you're using to view the validator messages (some
    sort of console?) can read the encoding that your program is emitting.

    - Oliver
     
    Oliver Wong, Dec 7, 2005
    #2
    1. Advertising

  3. Elhanan

    Elhanan Guest

    thanks, i allready figured out the eclipse espcially encodes propery
    files with i-8859- or something, and i have to change it to
    windows-1255, it's not only the validator that create question marks
    but just reading property files with bean:write.


    i'm using amateras strutside for struts.

    i'm hoping to find out if i can have the validator java script be
    activated on the field when i'm leaving it, to create or active
    apporeadch.

    btw in my search i've encounted a thread from 2001, saying struts is
    worthless and just creates overhead and bad performance issues, i
    wonder it's still true today.
     
    Elhanan, Dec 8, 2005
    #3
  4. Elhanan

    Elhanan Guest

    ok, narrowed it to the following:

    <%@ page contentType="text/html; charset=windows-1255" %>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <html>
    <body>
    <h3><bean:message key="welcome.heading"/></h3>
    </body>
    </html>

    if i use this welcome.heading will be displayed as question marks.
    if i remove the charset from the page directive, the contnet will be
    displayed as gibbirsh, but setting explorer's encoding to
    hebrew(windows) will get it write.
     
    Elhanan, Dec 8, 2005
    #4
  5. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > ok, narrowed it to the following:
    >
    > <%@ page contentType="text/html; charset=windows-1255" %>
    > <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    > <html>
    > <body>
    > <h3><bean:message key="welcome.heading"/></h3>
    > </body>
    > </html>
    >
    > if i use this welcome.heading will be displayed as question marks.
    > if i remove the charset from the page directive, the contnet will be
    > displayed as gibbirsh, but setting explorer's encoding to
    > hebrew(windows) will get it write.
    >


    That meants that the strings your emitting from Java are using the
    Hebrew(Windows) encoding. I strongly recommend you try to change it to
    either UTF-8 or UTF-16, but I can't offer you much advice on how to do that
    without seeing more info.

    Anyway, if what you've got works for you, then I suppose that's "good
    enough".

    - Oliver
     
    Oliver Wong, Dec 8, 2005
    #5
  6. Elhanan

    Elhanan Guest

    but i don't want it work this way, i want the browser to detect my
    encoding automatically.


    i tried to change to UTF-8, but the hebrew i got was gibbrish.
     
    Elhanan, Dec 8, 2005
    #6
  7. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > but i don't want it work this way, i want the browser to detect my
    > encoding automatically.
    >
    >
    > i tried to change to UTF-8, but the hebrew i got was gibbrish.


    The line that says:

    <%@ page contentType="text/html; charset=windows-1255" %>

    Is how your browser "automatically" detects the encoding. In other
    words, your browser is being TOLD what the encoding is, and it's being told
    incorrect information which is why it's receiving giberrish.

    My recommendation is that you change that tag to read:

    <%@ page contentType="text/html; charset=utf-16" %>

    and then, as an additional step, you have to make sure the data you're
    outputting actually IS in UTF-16 format. Once the two fields match up, your
    browser will be told to expect UTF-16 data, and it actually WILL receive
    UTF-16 data, and be able to display it.

    If you tell the browser to expect one kind of data, but then send
    another, then it's obviously going to be very confused.

    - Oliver
     
    Oliver Wong, Dec 9, 2005
    #7
  8. Elhanan

    Elhanan Guest

    here is what i did:
    <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>

    <body> test (written in hebrew)
    <h3><bean:message key="welcome.heading"/></h3>
    </body>
    </html>

    i first set my eclipse property editor encoding to utf-8,utf-16, and
    windows-1255 , i then set all tag pages as well (the page directive and
    the meta directive.)..
    on utf-8,utf-16, the word test came out as gibbrish, but in
    windows-1255 it came out ok, but in all cases the message from the
    properties came out as gibbrish, how do i change that?
     
    Elhanan, Dec 10, 2005
    #8
  9. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > here is what i did:
    > <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    > <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    > <html>
    > <head>
    > <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    > </head>
    >
    > <body> test (written in hebrew)
    > <h3><bean:message key="welcome.heading"/></h3>
    > </body>
    > </html>
    >
    > i first set my eclipse property editor encoding to utf-8,utf-16, and
    > windows-1255 , i then set all tag pages as well (the page directive and
    > the meta directive.)..
    > on utf-8,utf-16, the word test came out as gibbrish, but in
    > windows-1255 it came out ok, but in all cases the message from the
    > properties came out as gibbrish, how do i change that?


    When you say "came out as gibbrish", where do you see this gibbrish?
    From within Eclipse? From the console? From the browser?

    - Oliver
     
    Oliver Wong, Dec 12, 2005
    #9
  10. Elhanan

    Elhanan Guest

    from the browser.
     
    Elhanan, Dec 12, 2005
    #10
  11. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > from the browser.
    >


    And what encoding does the browser try to use when this happens?

    - Oliver
     
    Oliver Wong, Dec 12, 2005
    #11
  12. Elhanan

    Elhanan Guest

    well that's the confusing part, if i spacify in the page directive
    UTF-8, the browser really tries to have it in utf-8, i see the hebrew i
    hard coded encoded in jsp fine, but the from the property is gibbrish
    (and it also gibbrish in notepad if i look in 'view source') ,

    i omit the page directive, the browser displays it as western (iso)
    which is gibbrish, but changing to UTF-8 in ie dispalys hebrew
    correctly.

    is there a way to read a property file directoy from jsp with out
    struts (a jstl tag maybe?)
     
    Elhanan, Dec 14, 2005
    #12
  13. Elhanan

    Roedy Green Guest

    On 13 Dec 2005 23:10:05 -0800, "Elhanan" <> wrote,
    quoted or indirectly quoted someone who said :

    >well that's the confusing part, if i spacify in the page directive
    >UTF-8, the browser really tries to have it in utf-8, i see the hebrew i
    >hard coded encoded in jsp fine, but the from the property is gibbrish
    >(and it also gibbrish in notepad if i look in 'view source') ,


    the key fact you likely missed is that all properties files must be
    encoded in ISO-8859-1, e.g. using \uxxxx for all interesting
    characters.
    You can create them with native2ascii.
    See http://mindprod.com/jgloss/encoding.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Dec 14, 2005
    #13
  14. Elhanan

    Elhanan Guest

    i also tried that, still no go...

    an alternative solution somone offered me is to build my own
    propertties retriveal class using struts's interface and specify it in
    struts config, but i don't know how to do that.
     
    Elhanan, Dec 14, 2005
    #14
  15. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    >i also tried that, still no go...


    Are you saying the \uxxxx notation doesn't work? I.e. it doesn't display
    the hewbrew characters you are expecting?

    - Oliver
     
    Oliver Wong, Dec 14, 2005
    #15
  16. Elhanan

    Elhanan Guest

    exactly still gibbrish.
     
    Elhanan, Dec 15, 2005
    #16
  17. Elhanan

    Oliver Wong Guest

    "Elhanan" <> wrote in message
    news:...
    > exactly still gibbrish.


    The \uxxxx notation should bypass any encoding problems on the Java
    side, meaning that the in-memory string representations should be correct. I
    recommend you use the \uxxxx notation and then tweak your HTML encoding
    declaration and browser until you find a pair where they are no longer
    gibberish and work from there.

    - Oliver
     
    Oliver Wong, Dec 15, 2005
    #17
  18. Elhanan

    Elhanan Guest

    well i think i'v managed to a combo with eclipse ant builds so it would
    convert it automatilcaly for every build i do.
     
    Elhanan, Dec 17, 2005
    #18
    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. Bülent Keskin
    Replies:
    1
    Views:
    611
    Guy Soffer
    Aug 10, 2003
  2. J-T
    Replies:
    0
    Views:
    445
  3. PC Leung
    Replies:
    4
    Views:
    9,504
    greenleaf81
    Oct 22, 2008
  4. Replies:
    4
    Views:
    904
    Richter~9.6
    Feb 13, 2007
  5. Edwin Eyan Moragas

    nuby question: question marks in method names

    Edwin Eyan Moragas, Aug 30, 2004, in forum: Ruby
    Replies:
    0
    Views:
    139
    Edwin Eyan Moragas
    Aug 30, 2004
Loading...

Share This Page