first, the principle1, HttpServlet is first compiled from the source code to a class file, and then deployed to the server. The post-compilation deployment is first. 2, JSP is the first deployment of the source code compiled into a class file, the first deployment after the compilation. The JSP is compiled to the Httpjsppage class the first time the client requests a JSP file. This class is temporarily stored in the server's working directory by the server.
3. Example: When the client first requests myfirst.jsp, Tomcat first translates myfirst.jsp into standard Java source code myfirst_jsp.java, stored in% Tomcat_path%\work\cataline\localhost\ the%java_web% directory, and compile Myfirst_jsp.java as a class file myfirst_jsp.class. The class file is the corresponding Servlet. After compiling, run the class file to respond to client requests. In the future when clients access myfirst.jsp, the server will no longer recompile the JSP file, but megabytes calls the myfirst_jsp.class file.
second, the grammar(a) script1. <%%>:java code block2, <%=%>: Output3, <%!%>: Methods and global Variables
(ii) directives (can be substituted by JSP behavior tags <jsp:directive>) 1. Page directive: Specifies the properties of the JSP page. 1) Example:
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "errorpage=" "%> <%@ page import=" Java.util.Date "%>
2) Common properties:
2. include directive 1) Example: include.jsp contains head.jsp.
<% @include file= ". /common/jsp/head.jsp "%>
2) Nature: first include, then compile. the file contents of the include are already included in the compiled JSP . That is , the head.jsp source code is added to the include.jsp, and then compiled into a class file, which is first included after the compilation.
3. taglib directive:1) Example:
<%@ taglib url= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
(iii) JSP behavior1. Include Behavior:<jsp:include> 1) Example:include.jsp contains head.jsp.
<jsp:include page= "/head.jsp" flush= "true" ></jsp:include >
2) Nature: First run and then include. The runtime executes the head.jsp separately and then includes the results of the execution in include.jsp, which is the first run-after containment behavior. the contents of the head.jsp file are not included in the compiled include.jsp .
2. JavaBean Behavior:1) Define JavaBean object: <jsp:usebean id= "" class= "" scope= " "/>2) Get JavaBean property: <jsp:getproperty name= "" prperty= ""/> 3) Set JavaBean property: <jsp:setproperty name= "" prperty= "" Value= ""/>Where name is JavaBean, which is the ID property of the Usebean behavior, property is the JavaBean attribute, and value is the property value.
3. Forwarding Behavior:<jsp:forward>1) Example:
<jsp:forward page= "/somapage.jsp" > <jsp:param name= "param1" value= "value1" > <jsp:param Name= "param2" value= "value2" > </jsp:forward>
4, instruction behavior:<jsp:directive> equivalent to JSP instructions. 1) Example:<jsp:directive.page/> Behavior is equivalent to <%@ page%> directive. <jsp:directive.include/> behavior is equivalent to <%@ include%> directives. <jsp:directive.taglib/> Behavior is equivalent to <%@ taglib %> directive.
JSP Learning Note (i): JSP basics