JSP from shallow to deep (8) — JSP Tags

Another important syntax of JSP is tags. JSP tags does not use <%, but only the < character. JSP tag is a bit like HTML tag. JSP tags can have a "start tag", a "tag body" and an "end tag" 。 The start and end signs can use the name of the sign, which is circled in the < and > characters. The ending sign is to add a backslash (/) character after the character <. This sign name has an embedded colon (:) character in it, and the part before the colon describes the type of sign. For example:

body

If the flag does not need a body, the start and end flags can be combined, such as:

Here we use a / > instead of the > character, so that we can quickly end the flag without requiring an entity. This syntax is the same as that of XML.

Flags can be divided into two types: one is reproduced from the external flag library, and the other is a predefined flag. Predefined flags start with the jsp: character. For example, jsp: include is a predefined flag used to include other web pages.

In the previous tutorial, we have learned "include directive". In fact, it is very similar to JSP: include. They do not load the text of the included file in the original file, but call the included flag at run time. The following is an example of using jsp: include:

Going to include hello. jsp...< BR>

Now change "jsp: include" in the above code to "jsp: forward" to see the difference between them. In fact, these two predefined flags are very useful.

Let's give the exercise in this section again. Write a JSP to process an included file according to a boolean variable. Here's a hint. We need to use the mixed programming of HTML and scriptlets to deal with JSP flags.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>