The difference between a JSP and a servlet

Source: Internet
Author: User

1.jsp is compiled into a servlet. (JSP is the essence of SERVLET,JVM can only identify Java classes, not recognize the JSP code, the Web container to the JSP code into the Java class can be recognized)

The 2.jsp is better at showing on the page, and the servlet is better at logic control.

There are no built-in objects in 3.Servlet, and built-in objects in the JSP must be obtained by HttpServletRequest objects, HttpServletResponse objects, and HttpServlet objects.

JSP is a simplification of the servlet, using JSP only to complete the programmer needs to output to the client content, JSP Java script How to mosaic into a class, completed by the JSP container. The servlet is a complete Java class, and the service method of this class is used to generate a response to the client.

Teacher's Answer 1:

JSP is essentially a servlet, but the two are created differently. A servlet is a completely Java program code that is adept at process control and transaction processing through the servlet

To generate dynamic Web pages; JSP is composed of HTML code and JSP tag, can easily write dynamic Web pages

In practice, the servlet is used to control the business process, and JSP is used to generate dynamic Web pages. In the struts framework, the JSP is in the view layer of the MVC design pattern, and the servlet is at the control layer.

Answer 2:

JSP is an extension of the servlet technology, which is essentially a simple way of servlet. JSP is compiled "class servlet". The main difference between servlet and JSP is that the application logic of the servlet is in the Java file and is completely detached from the HTML in the presentation layer. In the case of JSP, Java and HTML can be combined into a file with a. jsp extension. The JSP focuses on the view, and the servlet is used primarily for control logic.

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.