Package mypack;
Import Java. Io. * ;
Import Java. util. * ;
Import Javax. servlet. * ;
Import Javax. servlet. HTTP. * ;
Public Class Helloworldexample1 Extends Httpservlet {
Public Void Doget (httpservletrequest request,
Httpservletresponse response)
Throws Servletexception, ioexception {
Response. setcontenttype ( " Text/html; charset = GBK " );
// First case
Printwriter out = Response. getwriter ();
Out. println ( " ------ In the first case, the output of Chinese characters is normal ------ " + " <Br> " );
// Case 2
Servletoutputstream out = Response. getoutputstream ();
Out. println ( " ------ In the second case, an error is reported in Chinese but the English language is normal ------ " + " <Br> " );
}
} AboveProgramThe following error occurs: Java. io. charconversionexception: Not an ISO 8859-1 character: No. The cause is that the binary stream output by stream does not encode the character. stream can only use characters encoded by ISO 8859-1, the text information output by writer is encoded by the system.