If you are doing ur XSL Transformation in your JSP Page , then you just
need to write

<%=transformer.transform(source, result); %>

That�s it.

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]] On Behalf Of
Fabrice Valois
Sent: Thursday, December 13, 2001 5:11 PM
To: [EMAIL PROTECTED]
Subject: Servlet / JSP / XML - to a MVC implementation ?


Today, i'm using JSP to perform the view. I also use JSP as controller.
Although view and controller are separated, I'm looking for a best way
to do this via XML/XSLT.

My approach is :

A request is sent to the web server :
- Controller (JSP) handles the request
- Controller (JSP) asks data to the model
- Model furnishes Datas (XML) to the controller
- The controller modifies data to perform request actions
- The controller forwards data modified to the view using XSL / XSLT


Here is an example, exactly what I want to do, a JSP handles the
request, performs some actions and sends data rendered by XSL :

<%@ page contentType="text/xml" %>
<?xml:stylesheet type="text/xsl" href="myxsl.xsl" version="1.0"
encoding="ISO-8859-1"?>

<doc title="foo">
<description>
        I'm a JSP. I'm processing the request.
<description>
<%
        while(request.getParameterNames().hasMoreElements())
        {
%> <item><%=(String)request.getParameterNames().nextElement()%></item>
<%
        }
%>
</doc>

But I want to perform the XSL Transformation on the server side to have
the full control using something like :

    StreamSource source = new StreamSource( THE XML response performed
by the JSP controller );
    StreamSource stylesheet = new
StreamSource("D:\\Dev\\web\\data.xsl");
    // Use a Transformer for output
   TransformerFactory tFactory = TransformerFactory.newInstance();
   Transformer transformer = tFactory.newTransformer(stylesheet);
   StreamResult result = new StreamResult(out); // out : to the client
web borwser
   transformer.transform(source, result);

I don't know how to forward the XML response of my JSP to the servlet
doing the XSL Transformation. Have an idea ? I have never seen example
using JSP / XML / XSLT that way. Am I going in a wrong way ? It sounds
like to me because the view is completly separated from the rest of the
application.

fv





-------------------------------------------------------------
This Message and any attachments are confidential and intended solely
for the addressees. And unauthorised use or dissemination are
prohibited. Emails are suceptible to alteration. Therefore neither
SWAPCOM nor any of its subsidiaries or affiliates shall be liable for
the message if altered, changed or falsified.

________________________________________________________________________
___
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to