Time to see the REAL generated servlet
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:
org.apache.jasper.runtime.HttpJspBaseIf 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:
package org.apache.jsp;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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access