JSP tutorial (IV)-Use of JSP actions

Source: Internet
Author: User

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 generateCode.

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.

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.