Chapter 15. JSPs and Servlets
JSPs are intimately tied with servlets. In Chapter 1, it was shown that servlets provide a componentized, efficient, Java-specific way of performing server-side operations. Servlets are essentially server-side software components. JSPs, working under the auspices of the servlet mechanism, actually make these components easier to create, modify, and maintain.
In Chapter 3, you were shown how the getServletContext()
method can be used within the jspInit()
and jspDestroy()
methods to access the servlet context object. Then, in Chapter 7, you learned how the Web container actually translates all JSP code into servlets during processing. It is this servlet code that is finally compiled and executed.
Up until this point in the book, there has been no detailed coverage of servlets. However, it is certainly very important to have an understanding of servlets as you head toward the more advanced application of JSPs. As a developer of Web-based applications and services using JSP, it is vital to be familiar with servlets, as many nonpresentation tasks are better implemented using servlets than with JSP. This difference will be highly evident in this and later chapters of the book, when larger and more complex Web applications and frameworks are presented.
This chapter presents Java servlets in their own right. Specifically, it describes the following:
How the Tomcat server treats servlets
The lifecycle of a servlet
Configuration of a servlet
How servlets can collaborate ...
Get Beginning JavaServer Pages™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.