Solved

about jsp,servlet -- contentType

Posted on 2001-06-28
5
961 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create a gui in perl 3 72
Java / Linux and Regular Expressions 11 71
Why my table column Id is not passed to java object? 4 28
use lov values 2 38
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now