What is JSP? JSP application instance: jsp application instance
Introduction: jsp is the abbreviation of Java Server Page. It is an extension of Servlet. His role is to simplify the website creation process and maintain dynamic websites. Html is more about displaying static pages. Servlet can display dynamic pages. jsp pages integrate html and Servlet. In addition to html text, jsp also contains the following content: (1) jsp command (2) jsp Declaration (3) jsp program fragment (4) jsp expression (5) jsp built-in object (the jsp built-in object is actually
Is the method parameter and local variable on the servlet service method)
Lifecycle: when a request contains a specific jsp page, it will process the jsp page as follows: (1) Find the corresponding servlet and call its service method if it exists. (2) if it does not exist
Servlet, parse jsp, translate it into source files, compile it into servlet classes, and initialize and execute it (jsp converted servlet is under the \ work directory of tomcat ).
1. Initialization phase: load the corresponding servlet (if not, parse the jsp file, translate it into the servletjava file, and compile the file) and create an instance, call the initialization method (the servlet initialization method generated by jsp is _ jspinit ()).
2. Running stage: run the servlet service method.
3. destruction method: Call the destroy method of servlet to destroy the instance.
Jsp request forwarding: tag of jsp request forwarding , The target component and source component share httpservletrequest,
Httpservletresponse object, and the code behind the tag will not be executed.
Jsp inclusion: jsp inclusion includes Dynamic and Static inclusion. <% @ include file = "absolute path or relative path" %> this command is static inclusion and only generates one servlet file,
Therefore, variables are shared between the source page and the contained page. Tags are dynamically contained. Different servlets are generated on the source and subpages.
At this time, the variables are not shared. (If flush is set to true, the request is returned before the sub-page is run)