Solved

about jsp,servlet -- contentType

Posted on 2001-06-28
5
965 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 50 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 84
Eclipse Java import and method not resolved 4 82
swing controls 2 23
Java array sort 10 35
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

726 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