1.JSP built-in objects: the JSP built-in objects is a set of objects created by Web container without manually can use new
2.JSP9 large built-in objects:
Object Name Type
Request (request object) the javax.servlet.ServletRequest
Response ( Response object ) javax.servlet.SrvletResponse
OUT ( output target ) javax.servlet.jsp.JspWriter
the session ( session Object ) javax.servlet.http.HttpSession the application ( application Object ) javax.servlet.ServletContext page (page object) javax.lang.Object pageContext ( page context object
) The javax.servlet.jsp.PageContext
config ( configuration object ) javax.servlet.ServletConfig
execption ( exception objects ) javax.lang.Throwable
3.JSP built-in objects: out
<% Int [] value = {60, 70, 80}; for (int I: value) { // output to the console to System.out.println ( "Console:" + I); // OUT as the most simple JSP built-in objects, primarily for outputting information onto the page Out.println (I); } %>
4.JSP built-in objects: request: the client sends a data request to the server, we receive data through the request object
<% Before the solution to solve the garbage // get the data submission of a form POST distortion Request.setCharacterEncoding ( "UTF-. 8"); // Request for acquiring the data submitted by the client to the server String username = request.getParameter ( "username" ); String password = request.getParameter ( "password"); // data acquisition component requests form a plurality of values corresponding String [] = hobbys request.getParameterValues ( "Hobby"); for (int I = 0; I < hobbys.length; I ++) { // Get the data to solve the garbage before the garbage solution form submission of Get / * hobbys [i] = new String (hobbys [i] .getBytes ( "ISO-8859-1"), "UTF- . 8 "); * / Out.print (hobbys [I]); } Out.println (); Out.println (username +" \ T "+ password); // gender String sex = request.getParameter (" sex " ) ; Out.println (Sex); // drop-down box address String address = request.getParameter ( "address" ); Out.println (address); %>
The difference between GET and POST:
1. From the security point of view post safer to get unsafe
to submit data may submit 2.post way about a few GB of data will get the greatest way to submit data to a few KB
5. solutions garbled:
post garbled solution: Request.setCharacterEncoding ( "UTF-. 8");
GET distortion solution: hobbys [I] = new new String (hobbys [I] .getBytes ( "the ISO-8859-1"), "UTF-. 8");
. 6 .HTTP status code:
1 ** information server receives the request, continue with the operations require the requestor to
2 ** successful operation has been successfully received and processed
3 ** redirection, further action is required to complete the request
4 client ** error, a syntax error or request contains a request can not be completed
5 ** server error, the server error has occurred during the processing of the request
404 and an error status code configuration page 500:
add the following configuration information in the current project which web.xml:
<error-page> <error-code>500</error-code> <location>/500.jsp</location> </error-page> <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page>
7.response: response
to forward (in-house servers, can not access to resources other than internal):
request.getRequestDispatcher("/response/welcome.jsp").forward(request, response);
Redirection (full path):
response.sendRedirect("/Chap02/response/Login.jsp");
the difference:
1. The forwarding is performed in the internal server redirects the client is complete, it is necessary to write the whole path, address XXXXXXX
2. forward the request once, the remaining operations are carried out inside the server; the redirection request at least twice, the rest of the request command again a client requests the URL of
3. can carry forward the requested data, with no data redirection
1.JSP built-in objects: the JSP built-in objects is a set of objects created by Web container without manually can use new
2.JSP9 large built-in objects:
Object Name Type
Request (request object) the javax.servlet.ServletRequest
Response ( Response object ) javax.servlet.SrvletResponse
OUT ( output target ) javax.servlet.jsp.JspWriter
the session ( session Object ) javax.servlet.http.HttpSession the application ( application Object ) javax.servlet.ServletContext page (page object) javax.lang.Object pageContext ( page context object
) The javax.servlet.jsp.PageContext
config ( configuration object ) javax.servlet.ServletConfig
execption ( exception objects ) javax.lang.Throwable
3.JSP built-in objects: out
<% Int [] value = {60, 70, 80}; for (int I: value) { // output to the console to System.out.println ( "Console:" + I); // OUT as the most simple JSP built-in objects, primarily for outputting information onto the page Out.println (I); } %>
4.JSP built-in objects: request: the client sends a data request to the server, we receive data through the request object
<% Before the solution to solve the garbage // get the data submission of a form POST distortion Request.setCharacterEncoding ( "UTF-. 8"); // Request for acquiring the data submitted by the client to the server String username = request.getParameter ( "username" ); String password = request.getParameter ( "password"); // data acquisition component requests form a plurality of values corresponding String [] = hobbys request.getParameterValues ( "Hobby"); for (int I = 0; I < hobbys.length; I ++) { // Get the data to solve the garbage before the garbage solution form submission of Get / * hobbys [i] = new String (hobbys [i] .getBytes ( "ISO-8859-1"), "UTF- . 8 "); * / Out.print (hobbys [I]); } Out.println (); Out.println (username +" \ T "+ password); // gender String sex = request.getParameter (" sex " ) ; Out.println (Sex); // drop-down box address String address = request.getParameter ( "address" ); out.println(address); %>
The difference between GET and POST:
1. From the security point of view post safer to get unsafe
to submit data may submit 2.post way about a few GB of data will get the greatest way to submit data to a few KB
5. solutions garbled:
post garbled solution: Request.setCharacterEncoding ( "UTF-. 8");
GET distortion solution: hobbys [I] = new new String (hobbys [I] .getBytes ( "the ISO-8859-1"), "UTF-. 8");
. 6 .HTTP status code:
1 ** information server receives the request, continue with the operations require the requestor to
2 ** successful operation has been successfully received and processed
3 ** redirection, further action is required to complete the request
4 client ** error, a syntax error or request contains a request can not be completed
5 ** server error, the server error has occurred during the processing of the request
404 and an error status code configuration page 500:
add the following configuration information in the current project which web.xml:
<error-page> <error-code>500</error-code> <location>/500.jsp</location> </error-page> <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page>
7.response: response
to forward (in-house servers, can not access to resources other than internal):
request.getRequestDispatcher("/response/welcome.jsp").forward(request, response);
Redirection (full path):
response.sendRedirect("/Chap02/response/Login.jsp");
the difference:
1. The forwarding is performed in the internal server redirects the client is complete, it is necessary to write the whole path, address XXXXXXX
2. forward the request once, the remaining operations are carried out inside the server; the redirection request at least twice, the rest of the request command again a client requests the URL of
3. can carry forward the requested data, with no data redirection