Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Syntax and description of JSP action elements

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the grammar and description of JSP action elements". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the grammar and description of JSP action elements.

JSP Action element

Unlike the JSP instruction element, the JSP action element works during the request processing phase. JSP action elements are written in XML syntax.

Using JSP actions, you can dynamically insert files, reuse JavaBean components, redirect users to another page, and generate HTML code for Java plug-ins.

Action elements have only one syntax, which conforms to the XML standard:

Action elements are basically predefined functions. The JSP specification defines a series of standard actions prefixed with JSP. The available standard action elements are as follows:

Grammatical description

Jsp:include introduces a file when the page is requested.

Jsp:useBean looks for or instantiates a JavaBean.

Jsp:setProperty sets the properties of JavaBean.

Jsp:getProperty outputs the properties of a JavaBean.

Jsp:forward directs the request to a new page.

Jsp:plugin generates OBJECT or EMBED tags for the Java plug-in based on the browser type.

Jsp:element defines dynamic XML elements

Jsp:attribute sets dynamically defined XML element attributes.

Jsp:body sets the dynamically defined XML element content.

Jsp:text uses templates for writing text in JSP pages and documents

. . .

Common properties http://www.iis7.com/a/lm/yczmljgj/

All action elements have two attributes: the id attribute and the scope attribute.

Id attribute: the id attribute is the unique identity of the action element and can be referenced in the JSP page. The id value created by the action element can be called through PageContext.

Scope attribute: this attribute is used to identify the life cycle of an action element. The id property is directly related to the scope property, and the scope attribute defines the lifetime of the associated id object. The scope attribute has four possible values: (a) page, (b) request, (c) session, and (d) application.

Action element

Action elements are used to contain static and dynamic files. This action inserts the specified file into the page being generated. The syntax format is on the right:

I have already introduced the include directive, which introduces the file when the JSP file is converted to Servlet, but the jsp:include action here is different, and the time to insert the file is when the page is requested.

The following is a list of attributes related to the include action.

Attribute description

The relative URL address that the page contains in the page.

The flush Boolean property that defines whether to refresh the cache before containing the resource.

. . .

Action element

The jsp:useBean action is used to load a JavaBean that will be used in the JSP page.

This feature is very useful because it allows us to take advantage of the reuse of Java components while avoiding the loss of the convenience that distinguishes JSP from Servlet.

The simplest syntax for a jsp:useBean action is:

After the class is loaded, we can modify and retrieve the properties of the bean through both the jsp:setProperty and jsp:getProperty actions.

The following is a list of attributes related to the useBean action:

Attribute description

Class specifies the full package name of the Bean.

Type specifies the type that will reference the object variable.

BeanName specifies the name of Bean through the instantiate () method of java.beans.Beans.

. . .

Action element

Jsp:setProperty is used to set the properties of an instantiated Bean object in two ways. First, you can use jsp:setProperty outside (behind) the jsp:useBean element, as shown below:

...

At this point, whether jsp:useBean finds an existing Bean or creates a new instance of Bean, jsp:setProperty executes. The second use is to put jsp:setProperty inside the jsp:useBean element

As follows:

...

At this point, jsp:setProperty is executed only when a new Bean instance is created, and jsp:setProperty is not executed if an existing instance is used.

At this point, I believe you have a deeper understanding of "the grammar and description of JSP action elements". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report