Functions of JSP actions

Source: Internet
Author: User

Functions of JSP actions
JSP actions use tags in XML syntax to control the behavior of the Servlet engine. JSP actions can be used to dynamically insert files, reuse the JavaBean component, redirect users to another page, generate HTML code for the Java plug-in, and define custom tags through the tag library
----- Start mark
----- End mark
------- Empty tag

Including:
<Jsp: include>
<Jsp: param>
<Jsp: forward>
<Jsp: plugin>
<Jsp: useBean>
<Jsp: setProperty>
<Jsp: getProperty>

<Jsp: useBean> tag

Create a Bean or obtain an existing Bean from the server

Syntax:
<Jsp: useBean name "name"/>
Or
<Jsp: useBean name "name">
Initialization code
</Jsp: useBean>

Jsp: useBean action is used to load a JavaBean that will be used on the JSP page. This function is very useful, because it allows us to take advantage of Java component reuse and avoid the convenience of JSP being different from Servlet!


After obtaining the Bean instance, you can modify the Bean attributes either through the jsp: setProperty action or by using the object variable named by the id attribute in the Scriptlet, you can call this object to explicitly modify its attributes.

Id attribute-unique Bean value referenced throughout the page
Bean name rules:
Unique
Case Sensitive
The first character must be a letter.
Spaces are not allowed.

You can specify different id values for the same Bean class.

Class attribute-name of the JavaBean class

--- Count Bean does not belong to the package
<Jsp: useBean/>
----- Count Bean belongs to the test package
<Jsp: useBean/>

Type attribute --------- type of the variable that will reference this object
BeanName attribute-specify the name of the serialized Bean

Scope attribute-indicates the Bean environment that should be available
---- Page
---- Session
---- Request
----- Application


Page scope
Store the JavaBean object in the javax. servlet. jsp. PageContext of the current page.
The JavaBean object can only be used on the current page.

Session scope
Store the JavaBean object in an HTTP session
The JavaBean object can be used for all pages within the lifecycle of the current HttpSession.


Request scope
Add JavaBean</

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.