Home >Web Front-end >HTML Tutorial >jsp template element

jsp template element

伊谢尔伦
伊谢尔伦Original
2016-11-26 10:13:051847browse

The static HTML content in the JSP page is called a JSP template element

2. JSP expression (expression)

A simplified way to output the calculation result of a java variable or expression to the client, it will output the variable Or the expression is directly encapsulated in <%= and %>

The variable or expression calculation result in the JSP expression will be converted into a string, and then inserted into the corresponding position of the entire JSP page output result

There cannot be a semicolon (;) after the variable or expression in the JSP expression. The JSP expression is translated into an out.print(...) statement in the Servlet program

3. JSP script fragment (scriptlet)

One or more pieces of Java program code nested in <% and %>

The Java code in the JSP script fragment will be moved intact into the _jspService method of the Servlet translated from the JSP page , so the JSP script fragment can only contain program code that meets Java syntax requirements

Any text, HTML tags and other JSP elements outside the script fragment will also be converted into corresponding Java program code and inserted into the _jspService method , and the position with the script fragment remains unchanged

The Java code in the JSP script fragment must strictly follow Java syntax. For example, each command execution statement must be ended with a semicolon (;)

In a JSP page, there can be Multiple script fragments (each script fragment code is nested between its own pair of <% and %>), text, HTML tags and other JSP elements can be embedded between two or more script fragments.

Codes in multiple script fragments can access each other

The Java statement in a single script fragment can be incomplete, but the result of the combination of multiple script fragments must be a complete Java statement

IV.JSP Declaration

JSP declaration encapsulates Java code in <%! and %>, the code inside it will be inserted outside the _jspService method of the Servlet

JSP declaration can be used to define the static code blocks, member variables and methods of the Servlet program converted from the JSP page (almost in JSP No)

5. JSP annotations

<%-- annotation information--%> JSP annotations

When the JSP engine translates the JSP page into a Servlet program, it ignores the annotated content in the JSP page

HTML comments

Difference: JSP comments can comment on Java code, but HTML comments cannot


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn