Q
Problem solve Get help with specific problems with your technologies, process and projects.

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?
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 last published in December 2002

Dig Deeper on Software containers

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide.com

SearchWinDevelopment

DevOpsAgenda

Close