The Superclass

The requirements for your superclass are as follows:

  • It must implement the HttpJspPage, if it uses the HTTP protocol, or JspPage, if it does not.

  • All methods from the Servlet interface must be declared final.

  • The service() method must invoke the _jspService() method.

  • The init() method must invoke the jspInit() method.

  • The destroy() method must invoke the jspDestroy() method.

A sample superclass servlet, which provides two utility methods for getting the username and company name, can be found in Listing 8.1.

Code Listing 8.1. PureJSPBase.java
 import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.HttpJspPage; import java.io.*; import java.util.*; public abstract class PureJSPBase extends HttpServlet implements ...

Get Pure Java Server 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.