JSP action Parsing

Source: Internet
Author: User

JSP actions control the behavior of the Servlet engine with tags in XML syntax format.

You can use actions to dynamically Insert Files. Reuse the JavaBean Component.

Redirects users to other pages to generate HTML code for the Java Plug-in.

 

1. include

Syntax: <jsp: include page = "include. jsp" flush = "true"/>

It always checks changes in the contained files and applies to dynamic pages.

You can also include parameters. page specifies the relative url containing the resource, but must be part of the same web application;

Flush must be defined and must be true; otherwise, a conversion error occurs.

 

<Jsp: include page = "" flush = "True"/> <! --, You can also pass a value to the included page through <jsp: param name = "" value = ""> <jsp: include page = "" flush = "True"> <jsp: param name = "" value = ""/> <jsp: param name = "" value = ""/> <jsp: param name = "" value = ""/> </jsp: include> <jsp: include page = "" flush = "True"/> <! --, You can also pass a value to the included page through <jsp: param name = "" value = ""> <jsp: include page = "" flush = "True"> <jsp: param name = "" value = ""/> <jsp: param name = "" value = ""/> <jsp: param name = "" value = ""/> </jsp: include>

Let's talk about static include. The result is to integrate other jsp into the current jsp without checking the file changes.

Introduce the syntax for static pages: <% @ include file = "include.html" %>

 

2. forward

Used to redirect an html or jsp file or program segment.

Syntax: <jsp: forword page = "path"> path indicates an expression or string.

 

3. useBean

Create a Bean instance on the jsp page and specify its name and scope.

Syntax: <jsp: useBean id = "name" scope = "page/request/session/application">

 

<Body> <jsp: useBean id = "xxx" class = "action. mySimpleTag "scope =" session "/> <jsp: getProperty name =" xxx "property =" value "/> <form action =" useBean. jsp "method =" post "> User Name: <input type = "text" value = "" name = "username"/> <input type = "submit" value = "SubMit"> </form> </body> <body> <jsp: useBean id = "xxx" class = "action. mySimpleTag "scope =" session "/> <! -- UseBean action --> <jsp: setProperty name = "xxx" property = "value" param = "username"/> <jsp: forward page = "testuseBean. jsp "/> </body> <jsp: useBean id =" xxx "class =" action. mySimpleTag "scope =" session "/> <jsp: getProperty name =" xxx "property =" value "/> <form action =" useBean. jsp "method =" post "> User Name: <input type = "text" value = "" name = "username"/> <input type = "submit" value = "SubMit"> </form> </body> <body> <jsp: useBe An id = "xxx" class = "action. MySimpleTag" scope = "session"/> <! -- UseBean action --> <jsp: setProperty name = "xxx" property = "value" param = "username"/> <jsp: forward page = "testuseBean. jsp "/> </body>

4. getProperty command

Obtain Bean attributes, convert them to a string, and insert them to the output page.

Syntax: <jsp: getProperty name = "name" property = "propertyName">

 

5. setProperty command

Used to set the attribute values in Bean.

Syntax: <jsp: setProperty name = "beanName" property = "propertyName">

 

6. plugin

Used to execute an applet or Bean Display object. If possible, you need to download a Java Plug-in to execute it.

 

7. param passing parameter tags

Syntax: <jsp: param name = "parameter name" value = "parameter value">

 

<Jsp: forward page = "url"> <jsp: include page = "url"> <! -- In combination, parameters are transferred when pages are redirected and included --> <jsp: forward page = "url of the redirection page"> <jsp: param name = "parameter 1" value = "parameter value 1"> <jsp: param name = "parameter name 2" value = "parameter value 2"> ........... </jsp: forward> <jsp: include page = "url"> <jsp: param name = "parameter 1" value = "parameter value 1"> <jsp: param name = "parameter name 2" value = "parameter value 2"> ........... </jsp: include> <SPAN style = "COLOR: #000066; FONT-SIZE: 14px "> <SPAN> </SPAN> <SPAN style =" FONT-SIZE: 14px "> <SPAN style =" COLOR: #000066 "> you can use <SPAN> request. getParameter ("</SPAN> parameter name <SPAN>") </SPAN> retrieves the corresponding value </SPAN> <SPAN style = "COLOR: #000066; FONT-SIZE: 14px "> </SPAN>

 

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.