Get the App
SLTechnology News&Howtos  ›  Development  › 

What does the JSP mark mean?

Shulou Source: shulou.com Published: 2022-06-02 12:23:57 09月30日 Update

This article will explain in detail what the JSP tag means. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. Overview

1) what is a JSP tag

As the name implies, the JSP tag is the tag used in the JSP file. It is similar to tags in html syntax, such as head, table. By referencing it in a JSP file (just like using html tags), it is easier to reuse Java code modules.

2) Why to use JSP tagging technology (compared with javabean)

Benefits:

The JSP tag can handle the content of the JSP body, such as changing the text display style, while javabean cannot.

JSP tag interface is simple, easy to use, and easy to develop and maintain.

Disadvantages:

JSP tags are much more complex to set up than javabean, as reflected in the configuration of the JSP tag library description file (* .tld).

JSP tags are not nearly as powerful as javabean.

Currently, as long as JSP1.1 supports JSP tags, JSP1.0 and 1.1 both support the use of Bean.

Brief introduction to the development of 2.JSP tags.

The development of JSP tags requires the writing of two separate files. One is the java class file that defines the tag function, and the other is the tag library descriptor file that maps the xml element name (tag) to the tag implementation.

Writing JSP tag handler class files with ⑴

Need to inherit the javax.servlet.jsp.tagext.TagSupport class

Simple example:

/ / File name ExampleTag.java importjavax.servlet.jsp.*; importjavax.servlet.jsp.tagext.*; importjava.io.*; publicclassExampleTagextendsTagSupport {/ / starting point of execution of the program publicintdoStartTag () {try {JspWriterout=pageContext.getOut (); out.print ("Customtagexample");} catch (IOExceptionioe) {System.out.println ("ErrorinExampleTag:" + ioe);} return (SKIP_BODY) / / return SKIP_BODY when the content included in the tag is empty, indicating that the marking function / / has been executed}}

The compiled class file will be located in a specific location on the server.

Writing JSP tag Library descriptor File by ⑵

Associate the tag name with the functional implementation it represents.

Simple example:

Tags: Tags processing files text methods programs content output attributes elements conditions information functions characters objects browsers examples development browsing engine Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Shulou Tech Info Huawei Shulou Technology