Q

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

Dig deeper on Java Web Services

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

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.

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close