A brief analysis of the basic syntax of the JSP getting started tutorial and a brief analysis of the jsp getting started tutorial

Source: Internet
Author: User

A brief analysis of the basic syntax of the JSP getting started tutorial and a brief analysis of the jsp getting started tutorial

This article describes the basic JSP syntax. We will share this with you for your reference. The details are as follows:

1. Command <% @ command %>

JSP commands are JSP engines. They do not directly generate any visual output, but only indicate what the engine needs to do for the remaining JSP pages. Command by <% @? %> Mark. The two main Commands are page and include. This article does not discuss the command taglib, but it is used when you create a custom tag in JSP1.1.

You can find the command page at the top of almost all JSP pages. Although not necessary, you can define such items as where to find Java class support.

<%@ page import="java.util.Date" %>

Indicates where the network user is guided when a Java running problem occurs:

<%@ page errorPage="errorPage.jsp" %>

Whether information needs to be managed at the user session level, which is likely to span multiple Web pages (this is described in more about JavaBeans ):

<%@ page session="true" %>

The "include" command can divide your content into more manageable elements, such as an element that includes a common page header or footer. The contained webpage can be a fixed HTML page or more JSP content:

<%@ include file="filename.jsp" %>

2. Declaration <%! Declaration %>

The JSP Declaration allows you to define the variables at the page level to save information or define the supported methods that may be required for the remaining JSP pages. If you find that you have written too much code, you 'd better write it into a separate Java class. Declared by <%! ? %> Definition. The variable Declaration must be ended by a semicolon, and any content must have a valid Java statement:

<%! int i=0; %>

3. Expression <% = expression %>

Through the expressions in JSP, the results of the calculated expressions are converted to strings and directly included in the output page. JSP string by <% =? %> Tag flag, unless it is a part of the referenced string, excluding semicolons.

<%= i %><%= "Hello" %>

4. Code segment/script segment <% code segment %>

The JSP code segment or script segment is embedded in "<%? '%>. This Java code runs when the Web server responds to the request. There may be pure HTML or XML code around the script fragment, where the code fragment allows you to create a condition to execute the code, or just call another piece of code. For example, the following code combines expressions and script fragments to display the string "Hello" in the H1, H2, H3, and H4 tags ". Script snippets are not limited to one line of source code:

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

5. Comment <% -- Comment -- %>

The last key element of JSP is about embedded comments. Although you can always add HTML comments to your file, once you view the page source code, you will see these comments. If you do not want users to see comments, embed them into <% --? -- %> Marked:

<%-- comment for server side only --%>

I hope this article will help you with JSP program design.

Articles you may be interested in:
  • Detailed description of JSP compiler-based basic syntax
  • Basic Syntax of JSP learning notes
  • JSP classic learning notes (including various common syntaxes for beginners)
  • JSP syntax Page command
  • Introduction to JSP development (II)-Basic Principles of JSP syntax
  • 11. JSP and syntax Overview
  • Client verification, common output methods, and basic JSTL usage in the JSP getting started tutorial
  • Summary of JSP basic statement usage
  • Functions and basic configurations of jsp web. xml files
  • Nine basic built-in components of JSP

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.