"Williams, Stephen" wrote:
>
> Hans Bergsten wrote:
> > One way I can think of is to use a common "wrapper" JSP page
> > that includes the before and after stuff, plus the real JSP
> > page, e.g.
> >
> >   <jsp:include page="before.jsp" flush="true" />
> >   <jsp:include page="<%= request.getParameter("mainJSP") %>" flush="true"
> />
> >   <jsp:include page="after.jsp" flush="true" />
>
> This seems like an excellent idea to me.  It would allow me to accomplish
> what I want without having to change any of my existing JSPs.  Additionally,
> it is much less error-prone than having to include files at the top and
> bottom of every JSP.
>
> However, can anyone think of any "gotchas" with using "jsp:include" on JSPs
> that were not originally intended to be included by another JSP?  I know
> that using RequestDispatcher.include() from a servlet restricts one from
> setting response headers and the response code -- will this present any
> issues with JSPs?

Yes, using <jsp:include> restricts the included JSP in the same way as if
included by RequestDispatcher.include(). Depending on what the before and
after JSP pages do, you may also want to restrict the HTML the main JSP
produces. For instance if before.jsp produces an <HTML> element, you do
not want to do that in the main JSP page as well.

What Jim Preston suggested is also an alternative, maybe even a better
idea if you plan to just put Java methods in before and after: encapsulate
the code in JavaBeans, or custom actions, instead.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

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