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.