I don't want to beat this into the ground, and I don't mean this to sound
argumentative, I'm just interested in discussing design issues like this. If
you use Hans Bergsten's suggestion then (as he himself indicated) all the
URLs that reference any of the JSPs in the set have to reference the wrapper
JSP and pass the actual JSP name as a parameter. It seems to me that having
that requirment is more error prone than the requrement of including
something at the top and bottom of the files.

In the include scheme, the engineer who sets up the pages has to remember to
add the include directives. I view this as part of the programming task; if
you don't trust your engineers to remember to add the includes, how can you
trust them to do any of the other thousands of things that are required to
make the system work? I mean, if you use a Java bean that needs to have
session scope, the burden is on the engineer to remember to add the scope
attribute to the usebean tag in every JSP. If you use a centralized error
handling JSP, it's up to the engineer to remember to include the errorpage
attribute on every page tag. Etc. etc. Anytime an engineer forgets to do
something, the system doesn't work right. I'm not sure I see how these
includes are any different.

In the wrapper scheme, anyone who ever does any editing or adding to the set
of JSPs needs to remember to reference the wrapper JSP and put the actual
JSP name on a parameter (and has to remember the right parameter name). If
you ever get to the point where you're using JSPs the way they were meant,
that is, that engineers set up the pages and do the coding, and then
designers edit and fix the HTML, it means that it will be the designers who
are dealing with -- possibly adding and changing -- the URLs.

So your choice of where to put the burden of remembering is between the
engineers at page creation time or the designers at any other time down the
road. Which one is less likely to be forgotten? Which one is more under your
control? Which one occurs less often? I'm not denigrating designers here by
implying that they can't be relied upon to remember things, but isn't it
part of our jobs as engineers to remove as much of the burden as possible
from the users (which, in some sense, designers are when it comes to JSPs)?

Finally, The wrapper-plus-parameter scheme exposes part of your engineering
design in the URLs. It takes a little bit of control out of your hands. What
if you ever wanted to have any of your JSPs accessed externally? Instead of
a simple, direct URL to the JSP, you have to tell the external site to use
this parameter scheme and hope that they get it right. And what happens if
someone (playfully or maliciously) enters the wrapper URL without the
parameter? You have to plan for that possibility and deal with it in some
reasonable way. If you use includes, this problem doesn't even come up.

--Jim Preston


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Williams, Stephen
Sent: Thursday, July 06, 2000 5:46 PM
To: [EMAIL PROTECTED]
Subject: Re: Extending JSP pages


Jim Preston wrote:
> Well, I'm curious as to why you think using an include to do
> what you want is kludgy and error prone. I guess I could
> maybe understand why you'd think it was a little kludgy if
> the code in question doesn't have anything to do with what's
> on the JSP, but what's error prone about it?

I'm not worried about the fact that the code doesn't have anything to do
with what's on the JSP.  I think it's kludgy and error-prone to have to
remember to put "<jsp:include begin.jsp />" at the top and "<jsp:include
end.jsp />" at the bottom of *every* JSP file I create.  I feel that that
it's kludgy because it clutters up every one of my JSP files.  It's
error-prone because it's easy to forget to put either the begin or end
include in one of the JSPs.

> In any case, why don't you just put your code in a method in
> a bean and then call that method from the JSP?
>     ...
> Or you don't even have to make it a bean...

Whether I do <jsp:include>, <%@ include%> or <% foo.bar() %>, I still have
to remember to do it at the top and bottom of every JSP file.  I'm trying to
avoid that if possible.

--
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

===========================================================================
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