The basic principles of CNET JSP basic:jsp Grammar

Source: Internet
Author: User
Tags define html page include
After the installation, we'll talk about JSP syntax. If you are lazy, you can download the grammar card and if you are unfamiliar with Java programming, you may want to refer to the Sun's manual; Web site creator should not do too much Java development. In addition to a few function calls, Java code that appears on your JSP page should minimize it;
With that in mind, let's take a look at the JSP compiler guidelines and instruction components, and then we'll explain JavaBeans and internal objects. The JSP compiler guidelines and instruction components have five types. JSP 1.0, most of the JSP is included in the <% as the beginning%> as the end of a single tag. The new JSP 1.1 specification has been published and is also compatible with XML.


Compiler guidelines and instruction components for JSP
Compiler guidelines <%@ Compiler guidelines%>
Declaring <%! Declaring%>
Op-<%= expression%>
Code fragment/Small instruction <% code fragment%>
Annotation <%--Annotation--%>


Compiler guidelines
The compiler guidelines for JSP are for the JSP engine. They do not produce any visible output directly; instead, they tell the engine how to handle other JSP pages. They are always included in the <%@?%> tag. The two main guidelines are page and include. We will not discuss taglib compiler guidelines but it can be used in JSP1.1 to create custom tags.

You can almost find page compiler guidelines on most of your JSP pages. Although this is not necessary, it allows you to specify where to find supported Java categories such things:
<%@ page import= "Java.util.Date"%>

Where should the message be routed when a Java problem occurs:
<%@ page errorpage= "errorpage.jsp"%>

And you are? To manage the information for the user during the call period, you may be able to access multiple Web pages (there will be more discussion in JavaBeans during the conversation):
<%@ page session= "true"%>.

The include compiler guidelines let you divide your content into manageable components, like those with headers or footnotes. The included pages can be either a fixed-format HTML page or a Web page of JSP content:
<%@ include file= "filename.jsp"%>.

Declared
JSP announcements allow you to define the variables of the page layer to store information or define the supported functions so that the rest of the JSP page can be used. If you find yourself with too many code, you'd better put them in a different Java class. You can find the announcement in the <%!?%> tag. Remember to add a semicolon to the back of the variable declaration, as in any valid Java narrative: <%! int i=0; %>.

Operational formula
There are expressions in the JSP, and the results of the evaluation expressions can be converted into strings and used directly on the output page. The JSP operation belongs to the <%=?%> tag and does not contain a semicolon, a useless part of the quoted string.

<%= I%>
<%= "Hello"%>.

Code Snippets/Small instruction files
The JSP code fragment or small instruction file is included in the <%?%> tag. This Java code executes when the network server accepts the request. A small instruction file can be raw HTML or XML, and its internal code snippets allow you to create conditional execution code or just something that uses another code. For example, the following code combines expressions with small instruction files, and displays the string "Hello" in H1,h2,h3 and H4 tags. The small instruction file is not limited to one line of source code:

<% for (int i=1; i<=4; i++) {%>
<H<%=i%>>Hello</H<%=i%>>
<%}%>.

Annotations
The last major JSP component is an embedded annotation. Although you can include HTML annotations in your files, users will see them if they view the original code of the page. If you don't want the user to see your annotation, you can put it in the <%--?--%> tag:

<%--the annotation--%> for the servo side.



Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.