Java meets HTML--JSP's JSP basic syntax

Source: Internet
Author: User

I. INTRODUCTION of JSP

The full name of the JSP is the Java Server Pages,java server-side page, which is simply a simplified servlet design that implements HTML tags for use in java. JSP is a dynamic Web page technical standard, which is executed on the server side.

Second, the common Dynamic Web site development technology

Common Dynamic Web Development technology comparison:

Java EE comparison is suitable for the following development:

Third, the JSP page element composition

3.1. JSP directive

The three main instruction elements of the JSP:

    • Page instruction Syntax:

Such as:

Note: pageencoding is the encoding of the JSP file itself, and Conttype's CharSet refers to the content encoding that the server sends to the client. Conttype are more commonly used.

3.2. JSP annotations

Comments on the JSP page.

There are three types of annotations that can be used on JSP pages:

Such as:

3.3. JSP script

The Java code that executes in the JSP page.

All statements written on this pair of tags can be considered JSP scripts.

3.4. JSP declaration

Define variables or methods in the JSP page.

Such as:

3.5. JSP expression

An expression that executes in a JSP page.

For example, call the function or variable declared above through an expression.

Operation Result:

Iv. the life cycle of JSP pages

The life cycle of the JSP page is that the user gives access to the JSP page, and if it is the first visit, the JSP engine will generate the JSP file as a servlet, generating the bytecode file execution Jspinit (), note that this method will only be used when generating bytecode files. That is, it executes only once in one life cycle, and then returns the bytecode file directly to the JSP page that is not the first time it is accessed.

Specific Description:

Attention:

1, the generation of bytecode files, execution Jspinit () only on the first request, the repeat request is executed only once. The generated file is in work, "Every time the modification is recompiled, a new bytecode file is generated."
2, Jspservice () to process user requests, for each request, the JSP engine creates a new thread to process the request "JSP Multithreading: Reduce resource requirements, increase system concurrency and response time, but pay attention to synchronization issues."
3. Because the servlet resides in memory, the response is very fast.

Ps: When a user first requests a JSP page, the first method to be executed is to construct the method.

V. Phases of the project

The expression is implemented in the following way:

Scripting Way to implement:

Note: An Out object is an instance of the JspWriter class that is used to output content to the client

Java meets html--jsp text JSP basic syntax

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.