Differences between Jsp and servlet

Source: Internet
Author: User

1. after compilation, jsp becomes Servlet. (The essence of JSP is Servlet. JVM can only recognize java classes and cannot recognize JSP code. Web containers compile JSP code into java classes that can be recognized by JVM)

2. jsp is better at page display and servlet is better at logical control.

3. No built-in objects exist in the Servlet. the built-in objects in Jsp must be obtained through the HttpServletRequest object, HttpServletResponse object, and HttpServlet object.

Jsp is a simplification of Servlet. To use Jsp, you only need to output the content that the programmer needs to output to the client. How to embed the Java Script in Jsp into a class is completed by the Jsp Container. Servlet is a complete Java class. The Service method of this class is used to generate a response to the client.

Answer 1 from the Instructor:

JSP is essentially a SERVLET, but the two are created in different ways. Servlet is completely composed of JAVA program code. It is good at Process Control and transaction processing, and through Servlet

To generate dynamic web pages. JSP consists of HTML code and JSP tags, allowing you to easily compile dynamic web pages.

Therefore, in actual applications, Servlet is used to control business processes and JSP is used to generate dynamic web pages. In the struts framework, JSP is located at the view layer of the MVC design mode, while Servlet is located at the control layer.

Answer 2:

JSP is an extension of Servlet technology, essentially a simple Servlet method. After JSP compilation, it is "servlet-like ". The main difference between Servlet and JSP is that the application logic of Servlet is in the Java file and is completely separated from the HTML in the presentation layer. In JSP, Java and HTML can be combined into a file with the extension. jsp. JSP focuses on views. Servlet is mainly used for control logic.

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.