Tomasz Ratajczak wrote:
>
> Hi All,
> I am struggling with XML / XSL transformation in the server. The scenario in
> which the transformation needs to take place is as follows:
> Model 2 web architecture - controller servlet forwards requests to main JSPs
> which in turn <jsp:include> mini JSPs. All pages generate XML.
> Transformation is to be used for separting L&F from data.
> Here is what I have tried so far:
>
> 1. Mapping *.jsp to a servlet that gets the NamedDispatcher to JspServlet
> and does include() with current request and a local response object which
> implements HttpServletRsponse.
> - this failed as the container (Tomcat) complained with ClassCastException
> on the response object. It expected to find HttpServletResponseFacade or
> something like that, which make sense because I was trying to cheat it into
> thinking that this is the actual request that it had created.
> - what I was trying to do here is to compensate for lack of servlet chaining
> or piping as referred to at http://java.apache.org/cocoon/dynamic.html .

Yes, the Servlet 2.2 spec explicitly says that the request and response
must be the ones provided with the original request. In Servlet 2.3, however,
this requirement may be changed (as per the 2.3 Public Draft).

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

> 3. (Have not tried this yet but something tells me it is not going to work)
> Extend the container specific JspServlet and override service() and pass a
> local HttpServletResponse object (similar to 1), it could work provided that
> internally JspServlet does not forward() or include(), otherwise we have (1)
> again.

Don't go there ....

> So where does this put me? Well I have architected something that cannot be
> implemented!!! It all made sense - we were using  IE to do the preliminary
> work with prototyping it and the transformation was done in the browser.
> Does it mean we have to change the design or wait for Netscape to support
> XML? This problem touches on the limitations of the Servlet API.
> And of course I might be missing something really important here.

I hope that the Struts framework solves your problem.

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