We’ve been looking at a super-simplified version of the servlet the Container actually creates from your JSP. There’s no need to look at the Container-generated code during development, but you can use it to help learn. Once you’ve seen what the Container does with the different elements of a JSP, you shouldn’t need to ever look at the Container-generated .java source files. Some vendors won’t let you see the generated Java source, and keep only the compiled .class files.
Don’t be intimidated when you see parts of the API that you don’t recognize. Most of the class and interface types are vendor-specific implementations you shouldn’t care about.
What the Container does with your JSP
Looks at the directives, for information it might need during translation.
Creates an HttpServlet subclass.
For Tomcat 5, the generated servlet extends:
If there’s a page directive with an import attribute, it writes the import statements at the top of the class file, just below the package statement.
For Tomcat 5, the package statement (which you don’t care about) is:
If there are declarations, it writes them into the class file, usually just below the class declaration and before the service method. Tomcat 5 declares one static variable and one instance method of its own.
Builds the service method. The service method’s actual name is
_jspService(). It’s called by the servlet superclass’ overridden service() method, ...