We use the extends directive in our current application but only because the
application was written long before JSP 1.0. We used a JSP implementation of
version 0.91 when there wasn't much information about good JSP design. So we
are living with this legacy in our current version. Our next version is a
complete rewrite and we don't use the extends tag for exactly the reasons
that you cite.

I suggest that you avoid the extends directive as well. The reason is that
when you use extends you are putting some severe restrictions on what kinds
of optimizations the JSP engine can perform under the hood. When you use
extends, you bypass whatever superclass the JSP container might have created
and have to use the more generic javax.servlet.http.HttpServlet base class
instead.

We now use a set of static includes that contain <%! .. %> declarations for
methods and data that we want to include on every page. This gives us
approximately the same functionality that we had with our extended JSP
servlets.

Since it is documented in the JSP 1.0 and 1.1 specification, I suspect that
the extends directive will continue to work in the future but I also suspect
that JSP engine authors won't expend too much effort to make JSPs that use
extends work efficiently. It is easy enough to avoid the whole issue with
any new development, which is good enough reason for me.


-----Original Message-----
From: Williams, Stephen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 06, 2000 1:07 PM

I'd like to have all of my JSP pages execute a certain chunk of Java code
before the page is displayed, and then execute another chunk of Java code
after the page is displayed.  I could use an "include" at the top and bottom
of each of my JSP pages, but this seems a little kludgy and error-prone.
Another way to do this might be to have all my JSPs extend a subclass of
HttpJspPage that I create.  However, I'm wary of doing this because Sun's
JSP documentation states that extending the JSP page "limits the JSP
container's ability to provide a specialized superclass that improves the
quality of the compiled file."

Does anyone have any experience with extending JSP pages through the use of
the "page extends" directive?  If so, what advice do you have for someone
thinking about doing it (e.g., gotchas, benefits)?

Alternatively, has anyone created a workaround for extending the JSP page
that accomplishes the same thing.

Thanks.

--
Stephen A. Williams
HNC Telecommunications Solutions

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to