?
Solved

about jsp,servlet -- contentType

Posted on 2001-06-28
5
Medium Priority
?
969 Views
Last Modified: 2013-11-24
in jsp i use this to set contentType

<%@page contentType="text/html;charset=gb2312"%>

but how to set it in servlet??
0
Comment
Question by:senuc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 9

Expert Comment

by:nimaig
ID: 6236850
HttpServletResponse.setContentType("text/html;charset=Big5");
0
 

Author Comment

by:senuc
ID: 6236922
i use solaris 5.8 ?{?@jdk1.3.1 + resin2.0
when I use
<%@page contentType="text/html;charset=gb2312"%>
the chinese words in jsp is right

but when i use

HttpServletResponse.setContentType("text/html;charset=gb2312"); or  
HttpServletResponse.setContentType("text/html;charset=Big5");

the chinese words all thange to ???
0
 
LVL 9

Accepted Solution

by:
nimaig earned 200 total points
ID: 6237407
Hi,
     Try this. I have not tried it.
//Hello World in CHINESE
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class JapaneseHelloWorldServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
response.setContentType("text/html");
response.setLocale(Locale.CHINESE);
PrintWriter out = response.getWriter();
out.println("<FONT SIZE=+2>");
out.println("\ u4eca\ u65e5\ u306f\ u4e16\ u754c");
out.println("</FONT>");
}
}
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6956194
senuc ->  Please click this link and update/finalize your old, open questions.
http://www.experts-exchange.com/jsp/memberProfile.jsp?mbr=senuc&showQHistory=true
Thanks,
Moondancer - EE Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question