aspose file tools*
The moose likes JSP and the fly likes German characters can't be displayed in a web page. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "German characters can Watch "German characters can New topic
Author

German characters can't be displayed in a web page.

Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
I have a JSP page which fetches the user names from the database and displays them in a drop down list through XMLHttpRequest.

The problem is the German characters are not displayed and replaced by question marks on the web page.

Those German characters are shown properly in the database and in the log file( I log the html output before send it back to the JSP file). When I print out the data through alert box, the German characters are shown as square boxes.

I tried to encode those German characters with 'UTF-8' and 'ISO-8859-1' before sending them back and decode them before showing them on the web page. But that doesn't make a difference and they are still shown as question marks.

I use IE 6.0 and it supports German characters and displays them when I visit sites in German languages. The Oracle database supports German. The JBoss application server runs on Linux box and/or Windows xp. I have the same problem no matter which JBoss I use.

What can I do to fix this problem?

Thank you.
[ January 18, 2007: Message edited by: Caly LeeAnn ]
Hongli Li
Ranch Hand

Joined: Oct 29, 2006
Posts: 124
I don't know if this helps.
I did a bilingual website, which has both English and French, I escape those non English words before I insert them to the database. Haver you tried the excapeXMl="false" option from the JSTL core taglib, the German should render correctly with that setting. I just guess since I have never worked with German. XMLhttpRequest, do you mean you render the menu with Ajax call, if so, I think you have to escape those no English Characters before insertion.
[ January 18, 2007: Message edited by: Hongli Li ]

Do you know why this cup is useful? Because it is empty.
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
Thank you for your reply. <cut> with escapeXml="false" doesn't work for me.

I am using the following way to handle the output.

function stateChanged_unameList() {
if (xhttp.readyState==4 || xhttp.readyState=="complete") {
var message = xhttp.responseText;
if ( message != null ) {
document.getElementById("unames").innerHTML = message;
} // if
} // if
}

I have tried to put page encoding like:

<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>

<html>
<head><title>/title>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">

I have tried 'ISO-8859-1' as well. None of them works. Are there something that I missed?
[ January 18, 2007: Message edited by: Caly LeeAnn ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I always post this article in response to questions like that.
Hongli Li
Ranch Hand

Joined: Oct 29, 2006
Posts: 124
you are welcome.



try this code to encode all those German characters before rendering. It works for French, not sure about German.
[ January 18, 2007: Message edited by: Hongli Li ]
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
One interesting thing is the German characters are displayed properly on the web page except in the drop down box which is created using a <select> element.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Two things, Caly:

First please use UBB Code tags when posting. (read this)

Seocndly, is the problem with characters as renderred by JSP when the page is initially loaded, or as a result of your Ajax call?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Two things, Caly:

First please use UBB Code tags when posting. (read this)

Seocndly, is the problem with characters as renderred by JSP when the page is initially loaded, or as a result of your Ajax call?
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
I will use the UBB Code tags.

It is a result of my Ajax call.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Thank you.

And, I'm going to shift this over to our HTML forum where Ajax issues are usually discussed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: German characters can't be displayed in a web page.