Hans Bergsten wrote:

> Tomasz Ratajczak wrote:
>
> > 2.Creating a custom BodyTag that would embrace the whole main JSP and do the
> > transformation in it.
> > - it also failed as the custom tag cannot contain <jsp:include> which we use
> > to include the mini JSPs (this is somewhat explained at
> > http://archives.java.sun.com/cgi-bin/wa?A2=ind0008&L=jsp-interest&P=R45529
> > and also in the JSP spec)
>
> You may want to look at the Apache Struts framework. It contains a number
> of useful custom actions, among others one that makes the data produced
> by another servlet or JSP page available as a String in the page scope:
>
>   <http://jakarta.apache.org/struts/struts-bean.html#include>
>
> This seems to be what you need.
>

While I appreciate the endorsement of Struts :-), the include tag mentioned here
only solves part of the problem.  You might also want to look at the <xsl:apply>
tag in the Jakarta Taglibs project <http://jakarta.apache.org/taglibs>.  This tag
lets you perform dynamic XSLT transformations.  The tag is really flexible about
where it gets the XML data and the XSL stylesheets from -- for either, you can
choose from any of:  a pre-existing JSP bean in any scope, a static resource in the
web-app, or the nested content of the tag (which is where an "include" capability
is useful).  There is also an <xsl:include> tag designed to work nested inside
<xsl:apply> for precisely this purpose.

Just as an example of one type of thing you can do, assume you've got a JSP page
with the following fragment, where "/my/stylesheet.xsl" identifies a static XSL
stylesheet in your webapp, and "/myservlet" is mapped to a servlet that dynamically
generates the XML that you want to apply styles to:

    <xsl:apply xsl="/my/stylesheet.xsl">
        <xml:include page="/myservlet"/>
    </xsl:apply>

What you get in your response page is the output of applying the specified static
stylesheet to the specified dynamic content.

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

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