struts validator question marks in messages

E

Elhanan

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

Oliver Wong

Elhanan said:
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
 
E

Elhanan

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

Elhanan

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

Oliver Wong

Elhanan said:
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
 
E

Elhanan

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

Oliver Wong

Elhanan said:
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
 
E

Elhanan

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

Oliver Wong

Elhanan said:
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
 
E

Elhanan

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

Roedy Green

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
 
E

Elhanan

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

Oliver Wong

Elhanan said:
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
 
O

Oliver Wong

Elhanan said:
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
 
E

Elhanan

well i think i'v managed to a combo with eclipse ant builds so it would
convert it automatilcaly for every build i do.
 

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,754
Messages
2,569,527
Members
44,997
Latest member
mileyka

Latest Threads

Top