aspose file tools*
The moose likes JSP and the fly likes Simplified Chinese in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Simplified Chinese in jsp" Watch "Simplified Chinese in jsp" New topic
Author

Simplified Chinese in jsp

Andrew Och
Ranch Hand

Joined: Mar 19, 2004
Posts: 32
Dear All
I am struggling with simplified chinese characters into my jsp pages. If the jsp pages contain only html and unicode chinese characters then the pages work fine. However if I put then put in jsp tags of any sort they simply get printed out in the browser verbatim (ie not interpreted). Worse still if I then include the chinese web page in another jsp page ie:
<%@ include file="/jsp/chinese.jsp" %>
All the chinese characters suddenly become ascii junk.
I have tried using a plain jsp page with:
<%@ page language="java" contectType="text/html; charset=UTF-8" %>
and then:
<%@ include file="/jsp/chinese.jsp" %>
If anyone has any ideas at all I am prepared to try anything?
Yours struggling desperately
Andrew Och
Rajaguru Ramalingam
Greenhorn

Joined: Apr 12, 2004
Posts: 11
Regarding ur problem,
1) Don't add the page directive in the chineese.jsp
2) Add the following 2 lines in the container jsp which includes that chineese.jsp
<%@ page contentType="text/html; charset=UTF-8" %>
<% request.setCharacterEncoding("UTF-8");%>
Hope this will solve ur problem.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Rajaguru,
JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "ur" instead of spelling out "your" may be convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not abbreviating these words.
thanks,
bear
JSP Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajaguru Ramalingam
Greenhorn

Joined: Apr 12, 2004
Posts: 11
Thanks Bear, I will be careful hereafter...
Andrew Och
Ranch Hand

Joined: Mar 19, 2004
Posts: 32
Dear Rajaguru
I added:
<%@ page contentType="text/html; charset=UTF-8" %>
<% request.setCharacterEncoding("UTF-8");%>
But still no joy.
Just to give some more background on my problem. I wrote the jsp page in notepad adding the chinese characters using Microsoft IME. When I then save it and move the jsp page to the Linux server running Tomcat and I view just this jsp page all characters work fine and html tags also (but not jsp tags).
Opening this jsp file in anything but notepad (eg vi, emacs, netbeans) shows mismash of junk hex looking characters. Also including it in a container jsp page the page prints out html verbatim and hex instead of chinese.
So another approach is if I write a JSP page in netbeans and then cut and paste the chinese characters they fist come out as two square and when saved and reopened change to ??.
I just want to put Chinese characters into jsp pages, how does everyone else do it?
Thank you very much for your help
Andrew Och
Andrew Och
Ranch Hand

Joined: Mar 19, 2004
Posts: 32
Dear Rajaguru
Oh dear I am so stupid. I saved the notepad version of the text as unicode instead of UTF-8. I have now resaved it as UTF-8 and added the lines you suggested into the container jsp:
<%@ page contentType="text/html; charset=UTF-8" %>
<% request.setCharacterEncoding("UTF-8");%>
and now it all works HOORAY!!!
Once again thank you very much for your help.
Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simplified Chinese in jsp
 
Similar Threads
JBoss Language problem
include tag
UTF-8 encoding problems
How to include a part of html code in to a jsp page?
INCLUDE syntax for html