What exactly happens behind the scenes when a JSP page is compiled? Is it converted to a servlet? If it is, then does each request to a JSP page result in the creation of a new servlet?
If it was successful, the generated servlet code is compiled, the servlet is loaded into memory by the JSP engine. At this point, the JSP engine also invokes the jspInit() method, and initializes the servlet. The jspInit() method is invoked just once during the lifetime of the servlet. Then the jspService() method is invoked to process the request and reply to the client. For all subsequent requests to the JSP page, the server checks to see whether the .jsp file has changed since it was last accessed. If there is no change, the request is handled by the jspService() method of the servlet stored in memory in a concurrent manner. Note that since the servlet is always stored in memory, the response is very fast.
If the .jsp file has changed, the server automatically recompiles the page file, replaces the servlet in memory, and handles the request as described above.