Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
| FAQ | Members List | 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 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 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


Reply With Quote
  #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.

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
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



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


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