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.