(24) Basic tag of JSP tag (<jsp: Tag name >)

Source: Internet
Author: User
Tags tag name

OneCommon Tags1.1 JSP in a total of 8 tags, which are commonly used in 6, this article will introduce the 6 commonly used tags. 1.2 6 kinds of label 1.<jsp:include>

The <jsp:include> tag indicates a file that contains either static or dynamic.

Grammar:
<jsp:include page= "path" flush= "true"/>
Or
<jsp:include page= "path" flush= "true" >
<jsp:param name= "paramname" value= "Paramvalue"/>
</jsp:include>

Note:
1. Page= "path" is a relative path, or an expression that represents a relative path.
2, flush= "true" must use flush to true, and its default value is False.
3, the <jsp:param> clause allows you to pass one or more parameters to the dynamic file, but also in a page
Use multiple <jsp:param> to pass multiple parameters to a dynamic file.

2.<jsp:forward> Tags
    • The <jsp:forward> tag indicates the redirection of a static html/jsp file, or a program segment.


Grammar:
<jsp:forward page= "Path"}/>
Or
<jsp:forward page= "path"} >
<jsp:param name= "paramname" value= "Paramvalue"/>
</jsp:forward>

Note:
1, page= "path" is an expression, or a string.
2, <jsp:param> name specifies the parameter name, value specifies the parameter value. Parameters are sent to a dynamic
File, the parameter can be one or more values, and the file must be a dynamic file. To pass multiple parameters
, you can use multiple <jsp:param> in one JSP file to send multiple parameters to a dynamic
File.

3.<jsp:useBean> Tags


The <jsp:useBean> tag is used to create a bean instance in a JSP page and specify its name to
and scope of action.

Grammar:
<jsp:usebean id= "name" scope= "page | Request | Session | Application "TypeSpec/>
There are several possible scenarios in which typespec:
class= "ClassName" | class= "ClassName" type= "TypeName" |
Beanname= "Beanname" type= "TypeName" | Type= "TypeName" |

Note:
You must use class or type, and you cannot use both class and beanname. Beanname says
The name of the bean, in the form of "A.B.C".

4.<jsp:getProperty> Tags

The <jsp:getProperty> tag represents the value of the property that gets the bean and converts it to a string, which
After inserting it into the output page.

Grammar:
<jsp:getproperty name= "name" property= "PropertyName"/>

Note:
1. Before using <jsp:getProperty>, you must use <jsp:useBean> to create it.
2. You cannot use <jsp:getProperty> to retrieve an attribute that has already been indexed.
3, can be used together with the JavaBeans components <jsp:getproperty>, but not with enterprise
With Java beans.


5.<jsp:setProperty> Tags
    • The <jsp:setProperty> tag indicates the value of the attribute used to set the bean.

Grammar:
<jsp:setproperty name= "Beanname" prop_expr/>
There are several possible scenarios in which prop_expr:
property= "*" | Property= "PropertyName" | Property= "PropertyName"
param= "ParameterName" | Property= "PropertyName" value= "PropertyValue"

Note:
Use Jsp:setproperty to assign a value to a bean's properties, which can be implemented in two ways.
1. Use Jsp:setproperty after Jsp:usebean:
<jsp:usebean id= "MyUser" .../>
...
<jsp:setproperty name= "user" property= "user" .../>
In this way, the Jsp:setproperty will be executed.
2, Jsp:setproperty appears in the Jsp:usebean tag:
<jsp:usebean id= "MyUser" ... > ...
<jsp:setproperty name= "user" property= "user" .../>
</jsp:useBean>
In this way, Jsp:setproperty will only be executed when the new object is instantiated.

* The name value in <jsp:setProperty> should be the same as the ID value in <jsp:useBean>.


6.<jsp:plugin> Tags
    • The <jsp:plugin> tag means executing an applet or bean, and, if possible, downloading a Java

The plugin is used to execute it.

Grammar:
<jsp:plugin
Type= "Bean | Applet
Code= "Classfilename"
Codebase= "Classfiledirectoryname"
[Name= "InstanceName"]
[archive= "uritoarchive, ..."]
[align= "bottom | top | middle | left | right"]
[height= "Displaypixels"]
[width= "Displaypixels"]
[hspace= "Leftrightpixels"]
[vspace= "Topbottompixels"]
[jreversion= "Jreversionnumber | 1.1"]
[nspluginurl= "Urltoplugin"]
[iepluginurl= "Urltoplugin"] >
[<jsp:params>
[<jsp:param name= "parametername" value= "{parametervalue | <%=
Expression%>} "/>]+
</jsp:params>]
[<jsp:fallback> text message for user </jsp:fallback>]
</jsp:plugin>

Note:
The <jsp:plugin> element is used to play or display an object in the browser (typically applets and
Bean), and this display requires a Java plugin in the browser.
When the JSP file is compiled and sent to the browser, the,<jsp:plugin> element will be replaced by the browser version.
Change to <object> or <embed> element. Note,<object> is used for HTML 4.0,<embed>
In HTML 3.2.
In general, the,<jsp:plugin> element specifies whether the object is an applet or a bean, and also specifies
The name of the class, and the location, also specifies where the Java plugin will be downloaded from.

(24) Basic tag of JSP tag (<jsp: Tag name >)

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.