Solved

about jsp,servlet -- contentType

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:

770 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