Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 3rd, 2004, 03:04 AM
Registered User
 
Join Date: Dec 2004
Location: , , Turkey.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default JSP encoding problem!

Hello,
I have got win 2000 pro. installed Tomcat 5.0.30 and Java 1.4.2_05 . I created "ISONedir.jsp" for control of charset like

below;
----
<%@ page contentType="text/html; charset=iso-8859-9" language="java" import="java.util.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
    <title>Charset</title>
  </head>
<body>
<%
  out.print(System.getProperty("file.encoding") + "<br />");
%>
</body>
</html>
----


I have written charset=iso-8859-9 as Jsp and HTML but appears "Cp1252" when runs "ISONEdir.jsp". I explored this on the net

before. I added somethings to catalina.bat like that -Djava.awt.headless=true -Dfile.encoding=iso-8859-9 .

catalina.bat
----
...%_EXECJAVA% %JAVA_OPTS% -Djava.awt.headless=true -Dfile.encoding=iso-8859-9 %CATALINA_OPTS% %DEBUG_OPTS%

-Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" ...
----


I got restart and run "startup.bat". appears "iso-8859-9" when runs "ISONedir.jsp".Its ok. But there is one problem with 'þ'

'ð' 'ü' 'ç' 'ý' Turkish characters when writing.
For testing cookie I created "CookieYaz.jsp" like this;

----
<%@page contentType="text/html; charset=iso-8859-9" language="java" import="java.util.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
    <title>Cookie</title>
  </head>
<body>
<form method="post" action="CookieYaz.jsp">
  <input type="text" value="" name="Adi" />
  <input type="submit" value="Submit" />
</form>
<%
  if (request.getParameter("Adi")!=null)
  {
    Cookie myCookie = new Cookie("Adi", request.getParameter("Adi"));
    myCookie.setMaxAge(24*60*60);
    response.addCookie(myCookie);
    %>
      <b>Adi: </b>"<%= request.getParameter("Adi") %>" olarak Kaydetti...<br />
      <a href="CookieOku.jsp">Oku</a>
    <%
  }
%>
</body>
</html>
----


I run "CookieYaz.jsp" and appeared some problems with I write "çiðdem güler" in name box and press submit button. the

problem is like this ;

----
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: çi?dem güler
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause

java.lang.IllegalArgumentException: çi?dem güler
    org.apache.tomcat.util.http.ServerCookie.maybeQuot e(ServerCookie.java:276)
    org.apache.tomcat.util.http.ServerCookie.appendCoo kieValue(ServerCookie.java:209)
    org.apache.coyote.tomcat5.CoyoteResponse.addCookie (CoyoteResponse.java:950)
    org.apache.coyote.tomcat5.CoyoteResponseFacade.add Cookie(CoyoteResponseFacade.java:291)
    org.apache.jsp.CookieYaz_jsp._jspService(CookieYaz _jsp.java:61)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
----


We tested this at linux. Everything is same. Same problems appear.
Could you help me please.
Regards,
Reply With Quote
  #2 (permalink)  
Old January 24th, 2005, 04:54 AM
Authorized User
 
Join Date: Feb 2004
Location: Jilin, Jilin, China.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cash
Default

why not use filter to change the charset it's realy good

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
encoding="utf-16" Problem francislang XSLT 7 April 10th, 2015 02:23 AM
Encoding problem. Neal XML 0 April 4th, 2006 06:49 AM
JSP encoding problem recepkocur Apache Tomcat 0 December 3rd, 2004 02:44 AM
JSP encoding problem! recepkocur Pro JSP 0 December 3rd, 2004 02:43 AM
JSP encoding problem recepkocur JSP Basics 0 December 1st, 2004 11:34 AM



All times are GMT -4. The time now is 08:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.