Common Jsp commands:
<% @ Page language = "java" contentType = "text/html; charset = gb2312"
Session = "true" buffer = "64kb" autoFlush = "true" isThreadSafe = "true"
Info = "text" errorPage = "error. jsp" isErrorPage = "true" isELIgnored ="
True "pageEncoding =" gb2312 "import =" java. SQL. * "%>
IsErrorPage: whether the Exception object can be used; isELIgnored: whether to ignore the EL expression;
<% @ Include file = "filename" %>
<% @ Taglib prefix = "c" uri = "http ://......" %>
(1) usage of the page command
• Specify high-level information for the servlet generated based on the JSP page
• Controllable
-Imported classes-extended servlet classes-generated MIME types-how to handle Multithreading
-Whether the servlet shares the session-the size of the output buffer-the page on which to handle unexpected errors
(2) import attributes
• Format
-<% @ Page import = "package. class" %>-<% @ pageimport = "package. class1,..., package. classN" %>
• Purpose
-Generate an Import Statement at the top of the servlet Definition
• Note
-Although JSP pages can be placed almost anywhere on the server
The class used by JSP must be placed in the regular servlet directory.
-Example:
... /WEB-INF/classes or
... /WEB-INF/classes/directoryMatchingPackage
• Packages must be used for practical tools used by JSP!
(3) contentType and pageEncoding attributes
• Format
-<% @ Page contentType = "MIME-Type" %>-<% @ page contentType = "MIME-Type; charset = Character-Set" %>
-<% @ Page pageEncoding = "Character-Set" %>
• Purpose
-Specify the MIME type of the page generated by the servlet generated by the JSP page
• Note
-Attribute values cannot be calculated during the request.
-For tables of common MIME types, see the section about response headers.
(4) session attributes
• Format
-<% @ Page session = "true" %> <% -- Default -- %>
-<% @ Page session = "false" %>
• Purpose
-The specified page is not part of the session.
• Note
-By default, it is a session.
-If the website traffic is large, the memory on the server can be saved.
-In order to truly play a role, all related webpages must do so.
(5) import attributes
-Changed the servlet import class generated by the JSP page
• Practical Tools must use packages!
• ContentType attribute
-MIME type of the specified result
-It cannot be used according to conditions.
• Use
<% Response. setContentType (...); %>
• ErrorPage and isErrorPage attributes
-Specify the "emergency" error handling page.
• IsThreadSafe attributes
-Disable concurrent access
-Use explicit synchronization instead of this attribute.
JSP has the following 6 basic actions:
Jsp: include: Introduce a file when the page is requested;
Jsp: useBean: Find or instantiate a JavaBean .;
Jsp: setProperty: Set the attributes of JavaBean .;
Jsp: getProperty: outputs the attributes of a JavaBean;
Jsp: forward: Transfers requests to a new page;
Jsp: plugin: generate the OBJECT or EMBED tag for the Java Plug-in based on the browser type.
JSP has the following nine basic built-in components (corresponding to the six internal components of ASP ):
Request: a client request that contains parameters from the GET/POST request;
Response: response from the webpage to the client;
PageContext: The webpage attributes are managed here;
Session: the session period related to the request;
Application: the content that the servlet is executing;
Out: used to send the response output;
Config: the framework of servlet;
Page: JSP page itself;
Exception: exceptions that are not captured for the error webpage.