The first knowledge JSP of the Java EE

Source: Internet
Author: User

The previous blog has briefly introduced the next servlet, from the previous blog, you can see that the servlet after the return of the data, the display to the client, the need for constant spelling, so as to form a complete HTML page, which in virtually increased the programmer's pressure and labor. Today, the JSP to be introduced just solves this problem.

In fact, JSP is one of the 12 specifications of the Java EE, it is the essence of the servlet, but JSP to sservlet encapsulation, making it more inclined to the presentation layer, with the HTML page, not only for business logic processing can also carry on the dynamic display of the Web page, compared to the servlet, Increased productivity and reduced programmer labor and stress.

Since the servlet has a life cycle, the JSP also has a life cycle, and the JSP life cycle is similar to Sservlet, the difference being that the JSP's life cycle also includes the JSP generation servlet.

Life cycle                    compilingincludes three phases: parsing the JSP, converting the JSP into a servlet, and compiling the servlet. Initialize

The JSP is initialized only once, and when the container loads the JSP, it creates an example and invokes the Jspinit () method to initialize it. If you need to perform a custom JSP initialization task, you can replicate the Jspinit () method.

Execution when the JSP Web page finishes initializing, the _jspservice () method is called. This requires a HttpServletRequest object and a HttpServletResponse object as its argument, _jspservice () The method is called once in each request and is responsible for generating the corresponding response.
destroyeddestroys Servelet instances. When a JSP page is removed from the container, the Jspdestroy () method is called, equivalent to the method of destruction in the servlet. When there are other needs, the Jspdestroy () method can be replicated, such as releasing the database connection or closing the folder. Examplejsp file

Execution Results           JSP and ServletJSP is a web development technology, and the servlet is a server-side running applet, when the JSP page is accessed, it compiles it into a servlet, and then the interactive results are returned to the client. JSP focuses more on the display of the page, while the servlet focuses on the processing of the business, that is, the JSP equivalent to the page, and the servlet to implement the JSP. Both embed the Java code in the JSP and embed the HTML code in the servlet when the page is displayed. SummaryJSP is similar to the HTML page, the same can be used for the display of the Web page, but the JSP embedded in the Java Code, HTML page can not embed a language code; JSP is the servlet, which compiles the JSP into a servlet at runtime and then processes the request from the client.     


The first knowledge JSP of the Java EE

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.