xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Kearney <bkear...@avolent.com>
Subject RE: SAX Filter Output in Servlet
Date Mon, 07 Oct 2002 22:51:57 GMT
You need to get the output writer from the servlt response, then set the
mime type and and content length on the response.

-- bk


> -----Original Message-----
> From: Bruce McDougald [mailto:bmcdougald@hotmail.com]
> Sent: Monday, October 07, 2002 4:55 PM
> To: xalan-j-users@xml.apache.org
> Subject: SAX Filter Output in Servlet
> 
> 
> I am having a problem sending html output as an http response 
> from my SAX
> transform.  I'm getting output to the system console when I 
> use System.out
> for my OutputStream, but thats no good for what I need.  From 
> the XALAN
> documentation, I'm supposed to
> create a PrintWriter object, but that is not compatable to 
> the Serializer
> object created in my SAX transformation code.
> 
> Can anyone tell me how to redirect the HTML output created from the
> serializer object back to the servlet?
> 
> Thanks.
> 
> Bruce
> 
> --------------------------------------------------------------
> ---------
> Here's my code:
> --------------------------------------------------------------
> ---------
>  ...
>       PrintWriter out = servletresponse.getWriter();
> 
>       XMLReader reader = XMLReaderFactory.createXMLReader();
> 
>       SAXTransformerFactory saxTFactory = ((SAXTransformerFactory)
> tFactory);
> 
>       XMLFilter xmlFilter1 = new SAXParse();
> 
>       xmlFilter1.setParent(reader);
> 
>       XMLFilter xmlFilter2 =
>                saxTFactory.newXMLFilter(new
> StreamSource("http://localhost/taymac.nsf/dynitmact.xsl"));
> 
>       xmlFilter2.setParent(xmlFilter1);
> 
>       // xmlFilter2 outputs SAX events to the serializer.
>       Serializer serializer = SerializerFactory.getSerializer
> 
> (OutputProperties.getDefaultMethodProperties("html"));
> 
>       serializer.setOutputStream(out);    // <--- System.out 
> was here in the
> example, but I need output to go back as servlet response!!!!!!
> 
>       xmlFilter2.setContentHandler(serializer.asContentHandler());
> 
>       xmlFilter2.parse(new
> InputSource("d:\\notes\\data\\domino\\cgi-bin\\itmact.xml"));
> ...
> 

Mime
View raw message