[Post] Use of JSP Action

Source: Internet
Author: User
Tags flush

JSP actions allows you to dynamically insert a file, reuse the JavaBeans component, forward to another page, or generate an HTML for the Java plug-in. The following actions can be used:
(1) jsp: include -- include a file when the page is requested.
(2) jsp: useBean -- Locate or instantiate a JavaBean.
(3) jsp: setProperty -- set a JavaBean attribute.
(4) jsp: getProperty -- insert the attributes of JavaBean to the output.
(5) jsp: forward -- enables the requester to go to a new page.
(6) jsp: plugin -- use the OBJECT or EMBED label to generate specific browser code for Java plugins.

1. jsp: include Action
This action allows you to include some files on the page to be generated:
<Jsp: include page = "relative URL" flush = "true"/>
Unlike include direve VE, this action contains the file only when the page is requested, while include directive contains the file when the JSP page is converted to servlet. To improve efficiency, include action makes a small sacrifice, that is, it does not allow the contained page to contain general JSP code (for example, HTTP headers cannot be set). However, it has significant flexibility. The following JSP code inserts four different fragments into the following page. Each time the title changes, you only need to modify the four files without changing the main JSP page.
WhatsNew. jsp
<HTML>
<HEAD>
<TITLE> JSP tutorial </TITLE>
<BODY>
<CENTER>
<Table border = 5 BGCOLOR = "# EF8429">
<TR> <th class = "TITLE"> What "s New at Chinese comic sites </TABLE>
</CENTER>
<P>
Here is a summary of our four most recent news stories:
<OL>
<LI> <jsp: include page = "news/Item1.html" flush = "true"/>
<LI> <jsp: include page = "news/Item2.html" flush = "true"/>
<LI> <jsp: include page = "news/Item3.html" flush = "true"/>
<LI> <jsp: include page = "news/Item4.html" flush = "true"/>
</OL>
</BODY>
</HTML>
Of course, you can define your own HTML file, but note the following:
You should put the file in the news directory under your JSP directory.
Jsp: useBean Action usage

I. Syntax:

<Jsp: useBean
Id = "beanInstanceName"
Scope = "page | request | session | application"
{Class = "package. class" |
Type = "package. class" |
Class = "package. class" type = "package. class" |
BeanName = "{package. class | <% = expression %>}" type = "package. class"
}
{/> |
> Other elements
</Jsp: useBean>
}
This action enables you to load a JavaBean into a JSP page. This is a very useful capability because it enables you to use reusable JAVA classes without sacrificing performance.
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.