Don't use a java.io.Writer to build a StreamResult, while use a File, 
so after the servlet has invoked Transformer.transform() you are able 
to forword to such a File.
i.e.:
don't do
StreamResult result = new StreamResult(out); // out : to the client web
but
StreamResult result = new File("result.jsp"); // out : to the client web
So after transform() return:
response.sendRedirect( "result.jsp")
or
getServletContext().getRequestDispatcher("/result.jsp").forward
(request, response)



> That's exactly what I want to do ! You understood precisly my goal : 
to have
> an action on the data depending on the client request. Thank you for 
your
> help. 
> 
> But I found 2 new problems :
> - all tags like <% have to be rewritten in < - that's make the code
> difficult to read but that's not the worth
> - XSL transforms the XML file into a JSP output but how can I tell the
> server to process this output instead of flushing it to the client ?
> 
> fv
> 
> 
> 
> -----Message d'origine-----
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Envoy� : jeudi 13 d�cembre 2001 13:21
> � : [EMAIL PROTECTED]
> Objet : Re: Servlet / JSP / XML - to a MVC implementation ?
> 
> 
> Don't make a JSP that build the XML, while treat your JSP as a simple 
> XML file, then delegate to the XSL file making the JSP.
> To be clearer:
> Make a JSP that receives the request
> then call from it the servlet (or jsp) that invokes 
> Transformer.transform() whose source is just such an XML file:
> 
> <doc title="foo">
> <description>
>         I'm a JSP. I'm processing the request.
> <description>
> <%
>         while(request.getParameterNames().hasMoreElements())
>         {
> %>
> <item><scriptlet><%=(String)request.getParameterNames().nextElement()%
> ></scriptlet></item>
> <%
>         }
> %>
> </doc>
> 
> Your data.xsl will have to be changed to include
> at the head:
> 
>              <%@ page contentType="text/xml" %>
> 
> and somewhere else:
> 
> <xsl:template match="scriptlet">
>      <xsl:apply-templates/>
> </xsl:template>
> 
> > 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 
reque
> st,
> > 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 
hav
> e 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
> > 
> >
> N<����r�>zǧu�sS[h-+-��ڲ�ܢf�v)�-�^S{ay��?�...�z�� z� z?
�HDU,D�51$���
> b��!�����?+޲6&hibar;j˧r?�j�!S���ǫ�W�S{^��-?٥E�(���m���j���w
(>�k&iexl;�oe���z��z�
> ��׫��kz�.�Ǭ?٥,""HDU�i?�i��0�[(~�(>�sz楳��z����
> 
> 
> -------------------------------------------------------------
> 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.  
> 
> 
> �{.n�+���zw^�����b����ڽ�.��&jwb��nu觶��ܨ~�^��,j��     �}�ER�L�SL
܆+޲m��ڭ�b��#j���w(���r�z��z��zا��޲�m�T^���q�!���6�j˧r������l�ǫ�W���mz�ږ�����z�m�R�I4�EQޖ�m����
%���r�����j[?�ǫ���f


Reply via email to