Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2004, 11:34 AM
Registered User
 
Join Date: Dec 2004
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 ve 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,





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 Servlets 1 January 24th, 2005 04:54 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





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