473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Servlet reponse give incorrect euro sign (?) character.. HELP!

SPG
Hi,

I am haveing some problems with getting the correct XML response from a
Servlet.
I have data that contains the euro sign ( 0x80 = ?) and the string I am
trying to print out to the response definitely has the correct formatting..
Here is some sample code:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class EncodingServlet extends HttpServlet implements
SingleThreadModel {
private static final String CONTENT_TYPE =
"text/xml;charset='iso-8859-1'";
private static String OUTPUT_XML = "<TEST val=\"£24 / ?40\"><STRING>£24
/ ?40</STRING></TEST>";

//Initialize global variables
public void init() throws ServletException {
}

//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
out.println(OUTPUT_XML);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}

As you can see, the string contains the euro sign, but the response always
replaces it with a '?'.
I have been battling with this one all day, is there anyone that can help
me?

Steve
Jul 17 '05 #1
2 5647
SPG
Hmm... As ypou can see.. Even the NG server has re-encoded the bloody
character!
Needles to say, the char code is 0x80

Cheers.

"SPG" <st************@nopoo.blueyonder.co.uk> wrote in message
news:ks*********************@news-text.cableinet.net...
Hi,

I am haveing some problems with getting the correct XML response from a
Servlet.
I have data that contains the euro sign ( 0x80 = ?) and the string I am
trying to print out to the response definitely has the correct formatting.. Here is some sample code:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class EncodingServlet extends HttpServlet implements
SingleThreadModel {
private static final String CONTENT_TYPE =
"text/xml;charset='iso-8859-1'";
private static String OUTPUT_XML = "<TEST val=\"£24 / ?40\"><STRING>£24 / ?40</STRING></TEST>";

//Initialize global variables
public void init() throws ServletException {
}

//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
out.println(OUTPUT_XML);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}

As you can see, the string contains the euro sign, but the response always
replaces it with a '?'.
I have been battling with this one all day, is there anyone that can help
me?

Steve

Jul 17 '05 #2
SPG wrote:
Hmm... As ypou can see.. Even the NG server has re-encoded the bloody
character!
Needles to say, the char code is 0x80


What character encoding are you using? In ISO 8859-15 or Unicode, the euro
sign is 164 (0xa4) IIRC.

--
Chris Gray ch***@kiffer.eunet.be
/k/ Embedded Java Solutions

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Zierhofer | last post by:
hi there, it seems as if i can´t convert the euro and pound sign to their html equivalents. i tried eregi_replace("€", "&euro;", $haystack); eregi_replace("£", "&pound;", $haystack); as...
2
by: Iain Toft | last post by:
I'm having problems displaying the ? euro dollar sign in XML produced from an XSL transform. SQL Server 2000 is used to produce XML (SELECT .. FOR XML) from a database table containing data. The...
11
by: MH | last post by:
Thai may have been asked before but I'm new here.... How can I put the Euro symbol, ? using alt0128 in my page and get it validated as HTML 4.01 ? -------------- MH
18
by: gabriel | last post by:
greetings, I am currently working on a website where I need to print the Euro symbol and some "oe" like in "oeuvre". If I choose this : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
4
by: rphil | last post by:
I have a problem, I want to enter euro sign (€) into a textbox.. but after the postback, it is displayed as '?' .Can anybody help me with this issue. Thx
7
by: kingski | last post by:
Any idea about this ? http://www.developerfusion.co.uk/forums/thread/114379/#114379 "Can any one help me as i am building a shopping cart and it supports multiple currencies but while sending...
0
by: kingski | last post by:
Any idea about this? http://www.developerfusion.co.uk/forums/thread/114379/#114379 "Can any one help me as i am building a shopping cart and it supports multiple currencies but while sending...
4
by: Kim | last post by:
Inserting a record through sql (asp, msaccess textfield), inserting the euro sign "?" shows up like a questionmark "?" in the output. I have <%@ LANGUAGE="VBSCRIPT" CodePage=28591 LCID=2077 %at...
3
by: Georg Weiler | last post by:
Hi, I have a database PostgreSQL entry that includes the string € which is the euro sign. When I retrieve the string through a PHP SQL statement and then echo the result to the browser, it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.