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
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.
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
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
posted 16 years ago
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
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad: