JSP Tutorial (iv) Use of-jsp actions

Source: Internet
Author: User
Tags flush include
js| Tutorial

JSP actions use you can dynamically insert a file, reuse the JavaBeans component, advance to another page, or generate an HTML for the Java plug-in. The action you can use is:

(1) Jsp:include--Included in a file when the page is requested.
(2) jsp:usebean--Find or instantiate a JavaBean.
(3) jsp:setproperty--sets a JavaBean property.
(4) jsp:getproperty--inserts the JavaBean attribute into the output.
(5) jsp:forward--allows the requester to move forward to a new page.
(6) jsp:plugin--uses the object or embed tag to generate a specific browser code for the Java plugins.

1. Jsp:include Action

This action allows you to include some files on the page you are about to generate:

<jsp:include page= "Relative URL" flush= "true"/>

Unlike include directive, this action is to include a file when the page is requested, and include directive contains files when the JSP page is converted to a servlet. In order to improve efficiency, include action makes a small sacrifice, that is, it does not allow the included pages contain generic JSP code (for example, cannot set HTTP headers), but it has significant flexibility, such as the following JSP code, it implements 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 Tutorials </TITLE>
<body >
<CENTER>
<table border=5 bgcolor= "#EF8429" >
<tr><th class= "TITLE" > What "s New at Chinese comic sites</table>
</CENTER>
<P>
We are 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 files, but one thing to note:

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.