struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Tomcat/Struts/XML/XSL
Date Mon, 12 Jun 2000 16:22:01 GMT
Kevin Duffey wrote:

> Hi,
>
> Probably been answered before..but I have a few questions about the overal
> combo of the subject.
>
> First, is Tomcat a 100% java written application, so it runs on any
> platform?
>

When you run Tomcat standalone, it is 100% Java and runs on any platform with an
appropriate JDK (currently 1.1 or higher).

When you run Tomcat connected to a web server (Apache, iPlanet, or Microsoft),
you need a connector module written in C that actually does the integration with
the webserver.  This code is (by necessity) platform specific.  The C source is
provided so that you can compile it for your platform, and pre-built modules for
several common platforms is available as well.

>
> Next, I was reading over Struts, and while everything looks great, I am
> wondering if it is possible to handle XML -> XSLT -> HTML with the
> framework, using cocoon? I don't know how stable the overall platforms are,
> and I know my company is going with WebLogic Server for our enterprise
> solution, but I believe its possible to use Struts and I was hoping I could
> start moving to XML to XSLT to HTML output.
>
> If it is possible, let me ask the Struts team this. If I have an action that
> returns Success/Failure, and in the config file (actions.xml) I have two JSP
> pages, the obvious flow is to forward to one of those two JSP pages. Is
> there any way to use an XML page instead, (if thats how it is done), and
> have the XML routed through the XSLT engine, supplying an XSL stylesheet for
> the transform, and have the response go back with the transformed html?
>

Note -- I responded in a message last night with how to have more than two
("success" and "failure") destinations if you need them, by extending the
ActionMapping class to include additional properties.

Routing of output from a JSP page (in this case) through some other processing
is not currently a feature of the servlet API.  Some servers have implemented a
thing called "servlet chaining" that does this, but the design is fraught with
problems and is not portable.  Work is ongoing in the expert group that is
discussing the next version of the servlet specs (will be version 2.3) to add
some sort of filtering capability, with the sort of transformation you are
talking about as a common use case.

>
> If not, I was wondering if this could be implemented in Struts, or for that
> matter, is anyone already doing this? I started my own framework based on
> the talks we had in jsp-interest with Craig and Daniel and a number of
> others (Model 2 discussions). My thought was, have the JSP page return XML
> (by setting the header to text/xml), and in the controller servlet, instead
> of forwarding to a JSP page, it would get a URL, read in the JSP page (into
> a stringbuffer), which would be XML formatted (because of the setHeader()
> call to use xml output), and then pass that through the cocoon servlet. I
> haven't seen cocoon yet, but I assume it returns the "transformed" content
> back to whoever calls it. Thus, the last part of the controller servlet
> would be to fill the response object with this content..so that it goes back
> to the browser.
>

As you have described it, the idea of doing transformations is generic to anyone
using JSP pages, not just those using Struts as their application framework.
Until the next servlet spec makes it possible to do this at the container level,
a couple of approaches to consider:

* Use a URLConnection to connect to yourself and read the output of the
  JSP page, presumably in the form of an XML document, and then apply
  the filter to it.  This is going to have substantial performance impacts,
  but it is feasible.

* Use Cocoon -- I don't know if you can insert JSP pages in the processing
  pipeline that Cocoon sets up, but if it is that might be a solution.  I will
need
  to spend some time looking at that.

* Write a custom tag that you would use to surround all the rest of your JSP
  page (which would then presumably be generating XML instead of HTML).
  The nested text would then be passed through an XSL stylesheet specified
  as an attribute; something like this:

    <struts:xsl stylesheet="xxxxx.xsl">
        ... original body of your JSP page ...
    </struts:xsl>

  This approach has the disadvantage of requiring you to modify every
  JSP page to include the surrounding tag, but it would be fairly easy to
  implement.  There is a similar tag in the jakarta-taglibs "xsl" library that
  we can use as a starting point.

* Modify the controller servlet to somehow swallow the output and do the
  transformation.  This would be a pretty substantial amount of work,
  because the controller servlet would need to provide a simulated
  environment to the JSP page so that it could wrap the output.  It will
  also be obsoleted by the new servlet spec.  But it could probably be
  done in a portable manner.

* Do the transformation in a RequestInterceptor (current Tomcat architecture)
  or Valve (Catalina architecture).  Although this is feasible, it is
  platform specific instead of being portable.

>
> Does this seem feasible..or even possible? If so, is this the right approach
> to take, or is there something already in the works to make all this work.
>

IMHO there is not necessarily only one answer to this.  The <struts:xsl> tag is
certainly easy to build, and I can go ahead and do that one, but it's not going
to solve everyone's problems.

By the way, this whole discusson is more relevant to take place on the
STRUTS-DEV list since it is talking about what kinds of changes to Struts might
be appropriate (rather than how to use what is already there).  Therefore, I've
"cc'd" the STRUTS-DEV list so that the folks not subscribed to both lists, but
might be interested in this discussion, can see it.

>
> Thanks.

Craig





Mime
View raw message