JSP2.0 Standard Commands, JSP automatic import package, JSP four major scopes, jsp2.0 four major
Three commands are defined in the JSP 2.0 specification:
Page command
Include command
Taglib command: import the JSTL tag Library to the JSP page. Replacing java code snippets in jsp
JSP automatically imports the following packages:
Import java. lang .*;
Import javax. servlet .*;
Import javax. servlet. http .*;
Import javax. servlet. jsp .*;
Static include: Include other resources to the current page.
<% @ Include file = "/include/header. jsp" %>
Dynamic include:
Difference between the two: Different Translation Time Periods
The former: merge the two files during translation.
The latter: files are not merged. The content of another file is included only when the code is executed to include.
Nine built-in jsp objects
Request Request object type javax. servlet. ServletRequest scope request
Response object type javax. servlet. SrvletResponse scope Page
PageContext Page Context object type javax. servlet. jsp. PageContext scope Page
Session Session object type javax. servlet. http. HttpSession scope session
Application Application Object Type javax. servlet. ServletContext Scope application
Out output object type javax. servlet. jsp. JspWriter scope Page
Config configuration object type javax. servlet. ServletConfig scope Page
Page Page Object Type javax. lang. Object scope page
Exception object type javax. lang. Throwable scope page
Four Scopes
PageContext: The data stored in pageConext is valid on the current page. It is rarely used during development.
ServletRequest: the data stored in the request is valid in one request (forward. It is used in many ways.
HttpSession: the data stored in the session is valid in one session. It is usually used. For example, it stores user login information and the shopping cart function.
ServletContext: The data stored by the application is valid throughout the application. Because the range is too large, use as few as possible
Forward () and redirect ()
Forward ():
The redirection of control in the container is the internal redirection of the server.
It directly reads the content displayed in the url, so the address bar will not change
The request value remains unchanged.
More efficient and easy to hide actual links
Redirect ():
Tell the client to resend the request link. The address bar displays the forwarded address.
The client sends two requests.
You can only use this
Objects within the Request range can be accessed by forward and cannot be accessed by redirect.