Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: