js| syntax JSP basic syntax
After you finish installing the problem, now go to the JSP syntax. An opportunistic way is to download the grammar card. If you are unfamiliar with Java programming, you may want to take a look at Sun's guidelines. However, web creators do not need to do much Java development. In addition to some method calls, you should use as little Java code as possible in your JSP pages.
With these tips in mind, let's take a look at the JSP directives and the scripting elements, and then we'll explain JavaBeans and suppressed objects. There are five kinds of JSP directives and script elements. In JSP version 1.0, most JSPs are surrounded by a tag that starts with "<%" and ends with "%>." After the updated JSP 1.1 specification was introduced, there was an XML-compatible version.
Instructions
JSP directives are designed for the JSP engine. They don't directly produce any visible output, but just tell the engine how to handle the rest of the JSP pages. These directives are always enclosed in the "<%@?%>" tag. The two most important directives are "pagepage" and "Include". The "Taglib" directive is not in the discussion column, but it can be used to create a custom tag with JSP1.1.
"Page" instructions are seen almost at the top of all JSP pages. Although not necessary, it allows you to specify:
Where to find the supported Java categories:
<%@ page import= "Java.util.Date"%>
Where to turn on the Web surfers when there is a Java run problem:
<%@ page errorpage= "errorpage.jsp"%>
and whether you need to manage the user's session-level information, which may come from multiple pages (further in the JavaBeans section below):
<%@ page session= "true"%>.
The include directive can divide your content into more manageable elements, such as an element that includes a normal page header or footer. The included web page can be a fixed HTML page or more JSP content:
<%@ include file= "filename.jsp"%>
Statement
JSP declarations allow you to define page-level variables to hold information or to define the support methods that may be required for the remainder of the JSP page. If you find that there are too many code, it is often best to write them in a separate Java class. Declarations are generally in the "<%!?%>" tag. Be sure to end the variable declaration with a semicolon (;) because any content must be a valid Java statement:
<%! int i=0; %>.
An expression
With a JSP expression, the expression evaluation result is converted to a string and is directly included in the output page. The JSP expression is contained in the "<%=?%>" tag without a semicolon unless the semicolon is used in the quoted string part.
<%= I%>
<%= "Hello"%>.
Code fragment/Script fragment
The code fragment/script fragment (Scriptlets) JSP code fragment or script fragment is embedded in the "<%?%>" tag. This Java code runs when the Web server responds to the request. There may be raw HTML or XML statements around the script fragment, where code snippets can allow you to create conditional execution code or code that uses another piece of code. For example, the following code combination uses expressions and snippets to display the string "Hello" in the H1, H2, H3, and H4 tags. Code snippets are not limited to one line of source code:
<% for (int i=1; i<=4; i++) {%>
<H<%=i%>>Hello</H<%=i%>>
<%}%>
Comments
The last major JSP element is an embedded annotation. Although you can always add HTML comments to a file, users will see the comments when they view the page source code. If you don't want the user to see it, you should embed it in the "<%--?--%>" tag:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.