I miss the old mailing list. People were *so* more helpful than here...
This sort of problem tends to occur when you have a code page mismatch somewhere.
Java runs in UTF8, databases have their own defaults (USACII7 on Oracle), and web-browsers tend to guess what code-page to use.
I have had similar problems to this many times over the last few years. Here is a list of things to check:
1. That your JDBC driver and database are set to use the same code page. Oracle (fat) drivers use the NLS_LANG settings to determine what code page to decode with. In Postgres the default is LATIN1, but you can override this in the JDBC URL.
2. If the the drivers and the database match correctly, the Java should happily convert your data into UTF8. You could test this by adding some log messages in your code.
3. If the String that java puts in your log messages is correct, then the problem must exist in how the web-browser is detecting the code page.
Check that any charset headers, or meta tags you are sending back contain the correct character set.
If you are not setting the character set anywhere, then this is probably your problem.
What version of struts are you using.
I had the same problem with struts 1.0,
it was fixed afterwards by one of the daily builds
and should have been rolled into version 1.0.2
So , if you are not yet using Struts 1.0.2, switch to the most recent release as that could solve your problem.
I'm not sure about which struts version I'm using -- I'll be updating to the latest nightly builds anyway. I'll be needing indexed tags.
My DB is PostgreSQL 7.0.x. All my databases are using UNICODE encoding. How do I check which encoding the driver is using and how can I specify it as a specific value?
I bet this is your problem.
The driver uses LATIN1 by default. This means that you have almost certainly got a mismatch.
According to the Postgres JDBC driver docs, you should be able to set the encoding in JDBC url, like this:
Unfortunately I have to report that I have not been able to get this to work.
Additionally if it does work, it probably only works in recent JDBC drivers.
I had exactly the same problem as you. My solution was to recreate the database with LATIN1 encoding, as this is the default used by the driver.
As you are only worried about ISO-8859-1 characters, this should work for you also.
I would also recommend upgrading you database to Postgres 7.1 or 7.2 as they added significant improvements to 7.1.
If you get it to work with UNICODE, I'd be interested to hear how, as I too would like to use UNICODE.
I think I just answered my own riddle.
The charSet property should be set to "utf-8" not "UNICODE" as I indicate above.
This seems to solve the problem.