Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Character encodings in complex enterprise environment  (Read 1676 times)
0 Members and 1 Guest are viewing this topic.
Offline lhkbob

JGO Knight


Medals: 32



« Posted 2009-05-09 02:13:14 »

First, some up-front warnings: this question has nothing to do with gaming, and most importantly, I'm not directly involved with the project that's failing (it's a friend's who I'm helping out debug).

Anyway, here it goes:
We have an online application that is in character encoding hell.  If we make a request to the server, with the é character in a url query parameter, the browser encodes it as %C3%A9.  The query parameter, as presented by struts and tomcat, treats %C3%A9 as é, which seems to be the Latin1 encoding.

This makes no sense to me, and it continues to happen, even when we force tomcat to use UTF-8 uri encoding.  To make matters worse, we get anomalous results when writing the query parameter out with a jsp.

For example, if the jsp did something like:
1  
2  
Query parameter: ${query}
Hardcoded: é

and the result, viewing the page with Latin1 character encoding would be:
1  
2  
Query parameter: é
Hardcoded: é

but when set to view as UTF-8, we get: (the value of query was still é, when it's stored as a String)
1  
2  
Query parameter: é
Hardcoded: ?

where the ? represents the unknown character symbol.

My jsp skills are not particularly great and we're at an utter loss as to what's causing these problems.  So I guess this is a hail mary request to see if anyone has any help.




Offline Mr. Gol

Senior Member


Medals: 1



« Reply #1 - Posted 2009-05-09 11:02:25 »

As for the last point, if you make sure that your JSPs are actually encoded as UTF-8 (use a decent text editor to check) and the HTML meta tag is also set to UTF-8, you will not have problems with hard-coded characters.

As for the problems with Tomcat and URL-encoding, I don't know. Since Struts magically passes URL parameters to actions it's hardcoded to use Latin1 for conversion?
Offline Json

Junior Member





« Reply #2 - Posted 2009-05-09 13:04:46 »

How are you forcing the tomcat URI encoding? Using the server.xml file?

// Json
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Immutate

Junior Newbie





« Reply #3 - Posted 2009-05-09 15:24:24 »

Json, it seems that struts is ust using the default j2ee spec character encoding, when none has been defined (ISO-8859-1). We recently just had this problem in our application. You should be able to force struts to use a different default character encoding via this method, which simply uses a servlet filter to set the encoding before struts has a chance to mangle the parameters.

PS: Also, make sure that whatever you're inspecting the output with something that is also UTF-8 encoded, otherwise you may not actuall be looking at the results you think you are.

- Immutate
Offline lhkbob

JGO Knight


Medals: 32



« Reply #4 - Posted 2009-05-09 20:58:28 »

Thanks for the replies, to tell Tomcat to use utf-8 we added the uri-encoding parameter to the server.xml (not sure exactly how it looks).

As for the last point, if you make sure that your JSPs are actually encoded as UTF-8 (use a decent text editor to check) and the HTML meta tag is also set to UTF-8, you will not have problems with hard-coded characters.
I can check the encoding of the jsps once the weekend is over.  Unfortunately I can't use <meta> tags because the generated jsp content is inserted into another page.

Json, it seems that struts is ust using the default j2ee spec character encoding, when none has been defined (ISO-8859-1). We recently just had this problem in our application. You should be able to force struts to use a different default character encoding via this method, which simply uses a servlet filter to set the encoding before struts has a chance to mangle the parameters.

PS: Also, make sure that whatever you're inspecting the output with something that is also UTF-8 encoded, otherwise you may not actuall be looking at the results you think you are.

- Immutate
This sounds like it could be our problem, we'll have to try it out.  Do you know how to change Eclipse's console to display different character sets?

Offline Immutate

Junior Newbie





« Reply #5 - Posted 2009-05-14 19:05:59 »

lhkbob, you can set the encoding for the Eclipse console in the settings for your run configuration. When you edit the settings for a run configuration, the console encoding is under the Common tab.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #6 - Posted 2009-05-14 19:58:29 »

Just to let everyone know, it was the problem with struts and its assumed character encoding.  Thanks for the help, everything seems to be working okay.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (72 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!