Package com.iamzken.test; Import java.io.*; Import java.util.*; Import javax.servlet.*; Import javax.servlet.http.*; public class Test extends HttpServlet { public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { Response.setcontenttype ("TEXT/HTML;CHARSET=GBK"); The first case PrintWriter out = Response.getwriter (); OUT.PRINTLN ("------The first situation of the output of Chinese normal------<br>"); Second case Servletoutputstream out = Response.getoutputstream (); OUT.PRINTLN ("------The second case output Chinese error but output English normal------<br>");
}
} The error is as follows: Type Exception Message Description The server encountered an internal error () is prevented it from fulfilling this request. exception Java.io.CharConversionException:Not an ISO 8859-1 character: part Javax.servlet.ServletOutputStream.print (servletoutputstream.java:89) Javax.servlet.ServletOutputStream.println (servletoutputstream.java:242) Com.iamzken.test.Test.doGet (helloworldexample1.java:43) Javax.servlet.http.HttpServlet.service (httpservlet.java:690) Javax.servlet.http.HttpServlet.service (httpservlet.java:803) Filters. Setcharacterencodingfilter.dofilter (setcharacterencodingfilter.java:122) Org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter (monitorfilter.java:196)
Stream outputs a binary stream that does not encode characters: Stream only applies to iso8859-1 encoded characters
Writer output is the text of the information, is carried out after the system code.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.