Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

struts validator question marks in messages

Thread view: 
Elhanan - 07 Dec 2005 07:49 GMT
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.
Oliver Wong - 07 Dec 2005 22:30 GMT
> 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
Elhanan - 08 Dec 2005 05:21 GMT
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 - 08 Dec 2005 06:36 GMT
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.
Oliver Wong - 08 Dec 2005 17:11 GMT
> ok, narrowed it to the following:
>
[quoted text clipped - 10 lines]
> 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
Elhanan - 08 Dec 2005 23:11 GMT
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.
Oliver Wong - 09 Dec 2005 16:16 GMT
> 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
Elhanan - 10 Dec 2005 16:35 GMT
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?
Oliver Wong - 12 Dec 2005 18:46 GMT
> here is what i did:
> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
[quoted text clipped - 15 lines]
> 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
Elhanan - 12 Dec 2005 22:08 GMT
from the browser.
Oliver Wong - 12 Dec 2005 22:36 GMT
> from the browser.

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

   - Oliver
Elhanan - 14 Dec 2005 07:10 GMT
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?)
Roedy Green - 14 Dec 2005 08:11 GMT
>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
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Elhanan - 14 Dec 2005 21:08 GMT
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.
Oliver Wong - 14 Dec 2005 22:32 GMT
>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
Elhanan - 15 Dec 2005 05:41 GMT
exactly still gibbrish.
Oliver Wong - 15 Dec 2005 22:55 GMT
> 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
Elhanan - 17 Dec 2005 19:39 GMT
well i think i'v managed to a combo with eclipse ant builds so it would
convert it automatilcaly for every build i do.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.