Common jsp commands, basic actions, and 9 built-in objects

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.