Solved

about jsp,servlet -- contentType

Posted on 2001-06-28
5
960 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
Comment Utility
HttpServletResponse.setContentType("text/html;charset=Big5");
0
 

Author Comment

by:senuc
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

771 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

10 Experts available now in Live!

Get 1:1 Help Now