javaee--jsp Introduction

Source: Internet
Author: User
Tags tomcat server

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

JSP Introduction:

The JSP full name is the Java Server Page, which is an extension of the servlet that simplifies the site creation process and maintains dynamic Web sites.
JSP operation principle:
The URL of the browser access index.jsp is http://localhost:8080/project name/ When the INDEX.JSP,TOMCAT server receives the client's access request, the server first goes to find the MyWeb project, finds the map to find the Jspservlet in the Web. xml file, then runs Jspservlet, then goes to the JSP object pool, asks if there are objects, and crawls object, and then call the service (Request,response) method to serve, if there is no object in the current directory to find the index.jsp file, locate the file to generate the file Index_jsp.java file, and then Index_ The Jsp.java file is compiled and loaded, the object is created to be put back into the pool, and then the object calls the service (Request,response) method to serve. As with Servlets, there is only one Jspservlet object throughout the life cycle.
Jspservlet in the Web. XML configuration file of the servers service:

The JSP access configuration is as follows: the. JSP and . Jspx access are sent to the JSP;

In general, Index.jsp generates Index_jsp.java files only when the client first accesses the JSP file. Tomcat places the Index_jsp.java source files and class files generated by the JSP in the work directory. During the development and debugging phase, if the developer modifies the JSP file, Tomcat will recompile the JSP and overwrite the new file generated by the build with the old file in the work directory.

Open Index_jsp.java to see his source code:

As can be seen in the source code, the servlet class corresponding to the JSP file inherits the Org.apache.jasper.runtime.HttpJspBase class, and the Httpjspbase class is provided by Tomcat, which implements the JSP The Javax.servlet.jsp.HttpJspPage interface in the API, which inherits the Javax.servlet.jsp.JspPage interface, and the Jsppage interface inherits the servlet The Javax.servlet.Servlet interface in the API.

Jspservice Service method is just a change of name, he is in fact the Servlet service method forwarded over;

The HTML text of the Index_jsp.java source file is called the template text and he will be sent to the client;

JSP syntax:
Although JSP is essentially a servlet, JSP has a special syntax that differs from the Java programming language, which is characterized by replacing Java program code with markup as much as possible, so that the entire JSP file is not formally like a Java program, but rather as a markup document.
In addition to directly containing HTML text in a. jsp file, you can also include the following:
JSP page directive: <%@ page%> main settings on the page parameters;

JSP Code directives:
<%%> Write code
<%! %> Application properties and methods
<%=%> Output parameters

Jjsp built-in objects:
Open index.jsp generated Index_jsp.java source file see the variable declaration to know which built-in objects, as follows:

javaee--jsp Introduction

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.