473,240 Members | 1,704 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,240 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 5642
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...

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.