Actually, I believe you CAN configure the web server so that all requests
for a "*.jsp" will be routed through a servlet of your choice first. I was
just reading about this in Jason Hunter's Servlets book, but unfortunately I
left it at home today. If you have the book, look it up, I think it's in the
section about servlet aliases. If no one else posts more on this by
tomorrow, I'll bring the book in and provide some details.
Assuming that this does work, the potential downside is that it's a totally
all-or-nothing solution; all JSPs will go through your servlet, and so
you'll either have to do that post- and pre-processing for all JSPs that are
ever served, or you'll have to have some logic in your servlet to determine
which ones need it and which ones don't. This might be great for your
environment, if you have total control over the server and all JSPs, but
it's not a very general solution.
--Jim Preston
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Williams, Stephen
Sent: Monday, July 10, 2000 11:39 AM
To: [EMAIL PROTECTED]
Subject: Re: Extending JSP pages
I, too, am very interested in discussing these issues. I hope my response
earlier didn't sound argumentative -- I was just trying to explain my
thoughts and concerns. I'd like to explain further my thoughts on the
matter:
Using the wrapper scheme, you pointed out that every JSP needs to be
referenced through the wrapper JSP, and that this extra work is at least as
much effort as the include scheme (and potentially more error-prone). I
agree! However, I had an idea for implementing the wrapper scheme that I
thought would alleviate this issue. It turns out my idea doesn't quite
work, but it's worth explaining.
Because our application uses a Model 2 architecture, all JSPs are invoked by
a controller servlet after the action classes have done their work (i.e.,
the JSP to invoke is passed into the controller servlet as a parameter).
Using this architecture, I planned on having the controller servlet send all
JSP pages through the wrapper JSP. Thus, the controller servlet would hide
all external knowledge of the wrapper JSP.
My idea works great for JSPs that are invoked as a result of servlet
processing. However, it doesn't do anything for JSPs that are invoked
directly from an existing JSP (or even a regular HTML page). I certainly
don't want to make the restriction that all JSPs must go through the
controller servlet, so that idea is out the window. Oh well.
For now, I am going with the include scheme. I don't see any way around it.
However, I am not happy with this solution and will be looking for a better
one. Extending the JSP page is still a possibility, as this hides almost
all of the complexity. However, I am still wary of the downsides of
extending a JSP page.
I also haven't given up on the wrapper scheme quite yet. If I could figure
out how to get all JSPs to pass through a wrapper / controller JSP first (or
even a regular servlet), I think that would work well. Can anyone think of
a way to do this via configuration of the servlet engine?
For instance, my servlet engine (JRun) currently maps all URLs matching
"*.jsp" to its JSP handlng servlet (JSPServlet). If I could change this to
route through my own servlet first and then to JRun's JSPServlet, that would
solve my problem. I actually think I might be able to do this with JRun,
but I don't want to do anything that ties me to JRun specifically. Has
anyone done something like this before?
If I could get the wrapper solution above working, it would not require
engineers or designers to add anything to their JSPs. Thus, it would be a
very clean solution with little chance for error. I would like that!
--
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