A JSP is a servlet, but it doesn't work the same way as HttpServlet. HttpServlet is deployed to the server after the source code is compiled into a class file, and is first compiled and then deployed. JSP is the first deployment of the source code after the compilation of a class file, first deployed after the compilation. The JSP is compiled to the Httpjsppage class (a subclass of the interface Servlet) the first time the client requests it. This class is temporarily stored in the server's working directory by the server. When the client first requests x.jsp, Tomcat first translates x.jsp into the standard Java source X_jsp.java, which is stored in the tomcat\work\catalina\localhost\jsp\org\apach\jsp directory and the X _jsp.java compiled as a class file X_jsp.class. The class file is the servlet corresponding to the JSP. After compiling, run the class file to respond to client requests. When the client accesses x.jsp in the future, the server will no longer recompile the JSP file, but instead call X_jsp.class directly to respond to the client request.
How JSP works (small pick)