JSP from simple to deep (8) — JSP Tags

Time:2022-5-30

Another important syntax for 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”. Both the start and end signs can use the name of the sign, which is enclosed in the < and > characters. The ending sign is the character < followed by a backslash (/). This flag name has an embedded colon (:) character inside, where the part before the colon describes the type of flag. For example:

<some:tag>

body

</some:tag>

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

<some:tag/>

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 an external flag library, and the other is a predefined flag. The 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. Instead of loading the text of the included file in the original file, they call the included flag at run time. The following is an example of using jsp:include:

<HTML>

<BODY>

Going to include hello.jsp…<BR>

<jsp:include page=”hello.jsp”/>

</BODY>

</HTML>

Now change the “jsp:include” in the above code to “jsp:forward” to see what the difference is. In fact, these two predefined flags are very useful.

Give the exercise of this section again, and write a JSP to modify an included file according to a boolean variable. Here’s a hint. You need to use the mixed programming of HTML and scriptlets to handle JSP flags.

Recommended Today

A front-end developer's Vim is the same as an IDE

Here is my new configurationjaywcjlove/vim-webI've been grinding it, and it's basically ready to use. Take it out and cheat the star Install The latest version of Vim 7.4+ uses (brew install macvim) installation, vim version updatebrew install macvim –override-system-vim View configuration locations # Enter vim and enter the following characters :echo $MYVIMRC download vim-web Download […]