request
response
exception
session
out
config
application
apge
Create global variables (member variables):
<%! String name = "" %>
4. Error type
500, JSP page in question (only write a redirection and forwarding)
404, can not find the page and access resources (address wrong address, the resource can not be found)
5.request object receives information
Background Gets the value of the front end:
request.getParameter ( "error"); quotation marks are the property name
6.response target response information
Redirect:
info = "user name or password is incorrect!";
/ * UTF-8 encoding statement format into a response formatted URL code * /
info =new String(info.getBytes("UTF-8"),"ISO-8859-1");
/ * The information in response to outgoing * /
/ * Redirect, close Servelt page, page and re-enter the client information passed through the URL passed in the past * /
response.sendRedirect("/newsDetail.jsp?error="+info);
Forward:
/ * Set the requested attributes (attribute name and attribute value) * /
request.setAttribute("info",info);
/ * * URL information forwarded back /
request.getRequestDispatcher("/login.jsp").forward(request,response);
7. garbage problem
post reception
/ * Client requests (messages sent by the front end) transcoding * /
request.setCharacterEncoding("UTF-8");
get reception
Convert the contents of the character set content URL
/ * Values or two types of encoding received URL, converts it into a byte array, the "ISO-8859-1" type of byte code is converted to byte array * /
byte [] infon = uname.getBytes("ISO-8859-1");
/ * The array and then converted to the encoding type UTF-8 encoding type * /
uname =new String(infon,"UTF-8");
/ * Write two together * /
uname = new String(uname.getBytes("ISO-8859-1"),"UTF-8");
By providing the conf server.xml file document file under the Tomcat node connector, add encoding = UTF-8
Redirect response
/ * UTF-8 encoding statement format into a response formatted URL code * /
String info = new String(uname.getBytes("ISO-8859-1"),"UTF-8");
/ * Garbled response * /
response.setContentType("UTF-8");
(Contains response.setCharacterEncoding ( "UTF-8") ;, provided the coding type the URL)
Forward response
/ * Server response (outgoing background information) transcoding, is the value obtained from the request or removed from a database value * /
response.setCharacterEncoding("UTF-8");