JSP2.0 Standard Commands, JSP automatic import package, JSP four major scopes, jsp2.0 four major

Source: Internet
Author: User

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.

Related Article

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.