Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Response encoding problem

Response encoding problem

2006-11-18       - By ruphus13

 Back
Reply:     1     2     3     4     5  

Hi - I'm trying to show utf-8 (See http://utf-8.ora-code.com) data in the browser from my jsp page.
When the page renders, its character encoding is iso-8859 (See http://iso-8859.ora-code.com)-1, according
to the browser.  The http
response headers have the same encoding (iso-8859 (See http://iso-8859.ora-code.com)-1).

Here's what's been done thus far:

1) meta tag set as follows:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8 (See http://utf-8.ora-code.com)"/>

2) jsp page encoding directive issued at the start of the jsp page.
<%@(protected) contentType="text/html; charset=UTF-8 (See http://UTF-8.ora-code.com)"%>

3) Generated jsp page has the following java code, as a consequence:
try {
    _jspxFactory = JspFactory.getDefaultFactory();
    response.setContentType("text/html; charset=UTF-8 (See http://UTF-8.ora-code.com)");
    pageContext = _jspxFactory.getPageContext(this, request, response,
              null, false, 8192, true);
    application = pageContext.getServletContext();
    config = pageContext.getServletConfig();
    out = pageContext.getOut();
    _jspx_out = out;
...
4) When I save the page as an html file and open it as an html file in
the browser, it renders correctly (due to the meta tag and no http
headers), which is expected.

5) Manually changing the page encoding in firefox results in the page
being rendered correctly.

6) Also set utf-8 (See http://utf-8.ora-code.com) in the connector settings in tomcat/conf/server.xml
(for GETs?)

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector Source code of org.apache.coyote.tomcat4.CoyoteConnector"
             port="8080" minProcessors="5" maxProcessors="75"
             URIEncoding="UTF-8 (See http://UTF-8.ora-code.com)" useBodyEncodingForURI="true"
             enableLookups="true" redirectPort="8443"
             acceptCount="100" debug="0" connectionTimeout="20000"
             useURIValidationHack="false" disableUploadTimeout="true" />

7) Set utf-8 (See http://utf-8.ora-code.com) in web.xml as follows:
<servlet>
      <servlet-name>jsp</servlet-name>
      <servlet-class>org.apache.jasper.servlet.JspServlet Source code of org.apache.jasper.servlet.JspServlet</servlet-class>
      <init-param>
          <param-name>javaEncoding</param-name>
          <param-value>UTF8</param-value>
      </init-param>
...

However, the page still shows up as iso-8859 (See http://iso-8859.ora-code.com)-1 (in firefox and IE),
and viewing the response headers using a 3rd party plugin shows the
content-type as ISO-8859 (See http://ISO-8859.ora-code.com)-1

Tomcat: 4.1.31
JDK: 1.4.2

What I'm hoping to learn is how to set the http response headers
correctly.  It seems that the generated java code is doing the right
thing.  However, the response header is still jacked...

Any help will be very, very much appreciated!  I've gone through
several articles on Goog as well as the tomcat mailing list... The
brick wall is getting bloodier, and I'm getting woozy from the
pounding...

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.