protected void PrintForm (HttpServletRequest req,httpservletresponse resp) throws servletexception,ioexception{
You must set the content Type before using PrintWriter
Resp.setcontenttype ("text/html;charset=gb2312");
PrintWriter out = Resp.getwriter ();
Output header
Out.print (Messageformat.format (strheader,new object[]{strtitle+ "-Please enter your name"});
Output form
Out.print (Messageformat.format (strform,new object[]{req.getcontextpath () +req.getservletpath ()));
Output footer
Out.print (Strfooter);
Out.flush ();
}
protected void Printhello (HttpServletRequest req,httpservletresponse resp) throws servletexception,ioexception{
Get data entered by the user
String name = Req.getparameter ("name");
if (name==null)
Name = "Anonymous";
Else
Make the necessary character encoding conversion for the data entered by the user
name = new String (name.getbytes ("iso-8859-1"));
You must set the content Type before using PrintWriter
Resp.setcontenttype ("text/html;charset=gb2312");
Output Welcome Information
Out.print (Messageformat.format (Strhello,new object[]{name}));
Output footer
Out.print (Strfooter);
Out.flush ();
}
protected void Printerror (String error, HttpServletRequest Req,httpservletresponse resp) throws Servletexception, ioexception{
You must set the content Type before using PrintWriter
Resp.setcontenttype ("text/html;charset=gb2312");
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.