Your JSP eventually becomes a full-fledged servlet running in your web app. It’s a lot like any other servlet, except that the servlet class is written for you—by the Container.
The Container takes what you’ve written in your JSP, translates it into a servlet class source (.java) file, then compiles that into a Java servlet class. After that, it’s just servlets all the way down, and the servlet runs in exactly the same way it would if you’d written and compiled the code yourself. In other words, the Container loads the servlet class, instantiates and initializes it, makes a separate thread for each request, and calls the servlet’s service() method.
The most important point for this chapter is simply: what role does your JSP code play in the final servlet class?
In other words, where do the elements in the JSP end up in the source code of the generated servlet?
Some of the questions we’ll answer in this chapter include:
Where does each part of your JSP file end up in the servlet source code?
Do you have access to the “servletness” of your JSP page?
For example, does a JSP have a concept of a ServletConfig or ServletContext?
What are the types of elements you can put in a JSP?
What’s the syntax for the different elements in a JSP?
What’s the lifecycle of a JSP, and can you step into the middle of it?
How do the different elements in a JSP interact in the ...