This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes UTF-8 issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "UTF-8 issue" Watch "UTF-8 issue" New topic
Author

UTF-8 issue

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
i use sql queries in my struts application.
since the information is in Hebrew i set the following settings:

1. db url: useUnicode=yes&characterEncoding=utf8
2. tomact catalina.sh: JAVA_OPTS="$JAVA_OPTS "-Dfile.encoding=utf-8"
3. in sql: i set the charcter encoding to UTF-8
4. server.xml on tomcat: useBodyEncodingForURI="true" URIEncoding="UTF-8"

but still, when i run it, i see in the log that it calls the DB with ??? values.
how can i solve the problem?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

odelya yomtov-glick wrote:but still, when i run it, i see in the log that it calls the DB with ??? values.
how can i solve the problem?

This may be because your logger has not support to the UTF-8 encoding OR you're not setting the logger's property for the same.

Have you able to execute the queries successfully ?

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
no.
i get the log:

DEBUG [http-12091-Processor25] - {pstm-100001} PreparedStatement: SELECT * FROM users WHERE NAME = ? AND PASSWORD = ?
DEBUG [http-12091-Processor25] - {pstm-100001} Parameters: [ביפר, ביפרילקוט]
DEBUG [http-12091-Processor25] - {pstm-100001} Types: [java.lang.String, java.lang.String]


which means that the characters are not being processed all right.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I repeat,
Sagar Rohankar wrote:Have you able to execute the queries successfully ?
Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
Thank you - i fount the mistake
The problem was that I had:
useUnicode=yes&characterEncoding=utf8

instead of:

useUnicode=yes&characterEncoding=utf8

in the url
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

odelya yomtov-glick wrote:
The problem was that I had:
useUnicode=yes&characterEncoding=utf8

instead of:

useUnicode=yes&characterEncoding=utf8

ohh..
How I missed that, but its a problem here, I though you posted like "& a m p;" and JR software turn it like "&", even code tags convert it:

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
ye
the browser converted it from "& a m p;" to &..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Those look the same to me.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

David Newton wrote:Those look the same to me.

Yep, that's looks same to me too at first place, but when I it, everything gets clear :mrgreen:
 
Don't get me started about those stupid light bulbs.
 
subject: UTF-8 issue
 
Similar Threads
Memory usage in JVM
Any advice how to tune GC?
supporting Unicode characters
tomcat 5 (jboss) handling hebrew chars
Character decoding in Java