20160327javaweb JSP Primer

Source: Internet
Author: User

first, what is JSP ? The JSP full name is Java Server Pages, which, like Servle technology, is a technology defined by sun to develop dynamic Web resources. The biggest feature of JSP technology is that writing JSP is like writing HTML, but it can only provide static data to the user compared to HTML, while JSP technology allows to nest Java code in the page and provide dynamic data to the user. For example, output the current time in a JSP page. Second, JSP principle
when the JSP page is first accessed, it is translated by the JSP translation engine into a servlet, from which the access to the JSP page is output by the servlet. Third, JSP Syntax

(1) JSP template elements: The HTML content written in the JSP page is called the template element of the JSP, and is directly exported to the browser page by Out.write () in the translated servlet.

(2) JSP expression <%= Java expression%> in a translated servlet, after calculating the value of the Java expression, it is output to the browser

(3) JSP script fragment <% several Java statements%> in the translated servlet, directly copied and pasted to the corresponding location execution.
You can have multiple script fragments in a JSP page that can embed text, HTML tags, and other JSP elements between two or more script fragments
Code in multiple script fragments can access each other as if all the code is in a pair of <%%>
The Java statements in a single script fragment can be incomplete, but the result of a combination of multiple script fragments must be a complete Java statement
(4) JSP declaration <%! several Java statements%> in the translated servlet will be placed in the same position as the service method, becoming a member of the class

(5) JSP annotations
The content of the <%--Comment is--%> commented out by the JSP annotation, which is discarded when the JSP translation engine translates the JSP into a servlet, without this information in the translated Servlet .
<%//java comments%> Java annotations are translated into servlets as JSP script fragments, and comment information is discarded when the. java file is translated into a. class file.
<!--HTML annotations and HTML annotations are exported as template elements to the browser, and the browser recognizes that HTML annotations are not displayed

20160327javaweb JSP Primer

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.