1. Example of session management 1.1 Continue to complete the cookie 1.2 URL to overrote Note: Three static pages write into servlet; action = ' response.EncodeURL ("step2") ' // Production Simulation sessionID 1.3 session survival 10 session-timeout> session-config> 2, processing exception 2.2 Actual abnormal 2.2 declarative abnormal 2.2.1 400, 404, etc. 404 404 < / error-code> / error/404.htm local> error-page> 2.2.2 servlet implementation Integer i = (Integer) Req.getaTRibute ("javax.servlet.error.status_code"); IF (I.intValue () == 401) Out.println ("401 Error"); if (I.intValue () == 404) Out.println ("404 Error"); 2.2.3 Program Error java.lang.arithmeticexception exception-type> / error/404.htm location> error-page> 3, security authentication 3.1 with Basic or Digest authentication, web. XML 3 Part 3 // Security Constrained Admin Web-Resource-Name> Admin'blog Description> / admin / * url-pattern> post http-method> get http-method> web-resource-collection> admin role-name> auth-constraint> security-constraint>
// Login configuration Digest or Basic Digest auth-method> login-config>
// Security role admin'blog description> admin role-name> security-role>
Join Tomcat-userS.xml: 3.2 is authenticated with Form, 3 parts: 3 parts of Web.xml Login Web-Resource-Name> Admin'blog description> / login / * url-pattern> Post http-method> get http-method> web-resource-collection> login role-name> auth-connection > Security-constraint> form auth-method> /login/auth.htm form-login- Page> /login/error.htm form-error-connection> flm-login-config> login-config> Login'blog Description> login role-name> security-role> 3.2.2 Tomcat-users.xml Add role:
3.2.3 AUTH.HTM should pay attention to three points (must be defined): action = "j_security_check" name = "j_username" name = "j_password"
4, thread safety (whether there is an impact of mutual resources) 4.1Case Int i = 0; // Global variables, class variables, session variables, servletContext, threads are not secure, use Implements SingleThreadModel to implement thread security. INT i = 0; // Local variable, request variable REQ, thread security.
5, JSP 5.1JSP Note <% - Comments -%> <% // - Comments -%> <% / * comments * /%> // HTML Note