Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
| Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP 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
  #1 (permalink)  
Old August 2nd, 2005, 10:18 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default charset question

I want to use charset="GB2312" in JSTL,and input information with GB2312 code in index.jsp page and then I post it to show_parameters.jsp page,I find the charset is not show properly. It shows some '?'.
Why? My code is follows:

*********index.jsp**************
<html>
<head>
<title>Request Decoding by Hand</title>
</head>
<body>
<%@ taglib uri='http://java.sun.com/jstl/fmt' prefix='fmt'%>
<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>
<%@ page contentType='text/html; charset=GB2312' %>
<fmt:setLocale value='zh'/>
<fmt:setBundle basename='app'/>
<fmt:message key='login.form.title'/>
<form action='show_parameters.jsp'>
<table>
<tr>
<td><fmt:message key='login.textfield.name'/></td>
<td><input type='text' name='name' value='<fmt:message key="login.textfield.nameValue"/>'/> </td>
</tr></table> <br>
<input type='submit' value='<fmt:message key="login.button.submit"/>'/>
</form>
<c:set var='requestCharset' value='GB2312' scope='session'/> Response Charset: <c:out value='${pageContext.response.characterEncoding}'/>
</body>
</html>

********show_parameters.jsp***********
<html>
<head>
<title>Request Decoding by Hand</title>
</head>
<body>
<%@ taglib uri='http://java.sun.com/jstl/fmt' prefix='fmt'%>
<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>
<%@ page contentType='text/html; charset=GB2312' %>
<% String charset = (String)pageContext.getAttribute("requestCharset", PageContext.SESSION_SCOPE); request.setCharacterEncoding(charset); %> Request Charset: <c:out value='${pageContext.request.characterEncoding}'/>
Name: <c:out value='${param.name}'/> Request Charset: <c:out value='${pageContext.request.characterEncoding}'/>
</body>
</html>

********app_zh.properties***********
login.page.title=\u8bf7\u767b\u5f55
login.form.title=\u8bf7\u767b\u5f55
login.textfield.name=\u7528\u6237\u540d
login.textfield.nameValue=\u7528\u6237\u540d\u767b \u5f55
login.textfield.pwd=\u5bc6\u7801
login.button.submit=\u767b\u5f55


  #2 (permalink)  
Old August 8th, 2005, 03:09 PM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's just a guess, but might it not be a good idea to move the contentType all the way up, as the first line in the JSP file? Makes more sense to me.



Similar Threads
Thread Thread Starter Forum Replies Last Post
page.response.charset manoj.aggarwal ASP.NET 2.0 Professional 0 August 1st, 2007 03:55 AM
incorrect charset when reading the jsp form m.walter@fue-gmbh.com Struts 0 October 9th, 2006 09:59 AM
change charset vincentc Classic ASP Basics 1 May 31st, 2005 04:00 AM
problem in mysql php charset yoord BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 11th, 2005 03:40 AM
charset encoding bservi XML 0 May 3rd, 2004 07:32 PM





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