How can I dangle JSP off of non-container servlets?

How can I dangle JSP off of non container servlets? i.e., I have several reusable servlets that have an inheritance object model. I want to take advantage of extending JSP's off of my child classes. Basically I want to have JSP's extend MyServletBlahBlah servlets instead of the generic container servlet?

    Requires Free Membership to View

Typically a JSP is parsed and converted to an instance of HttpJspPage. HttpJspPage extends JspPage, which extends Servlet. However, it is possible to force a JSP to extend a specific class using the page directive as follows:

<%@ page extends="com.apackage.AServlet" %>

In this example the JSP will end up extending com.apackage.AServlet. Forcing a JSP to extend a class other than the default class provided by the JSP vendor should be done wisely and sparingly, since the default superclass provided by the JSP vendor may contain optimizations and other needed custom behaviors.

This was first published in December 2002

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.