You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@apache.org on 2001/04/23 20:53:45 UTC
cvs commit: xml-xalan/java/samples/servlet XSLTServletWithParams.java
dleslie 01/04/23 11:53:43
Modified: java/samples/servlet XSLTServletWithParams.java
Log:
1. Updated per comments by Albert Tsun about including
charset=UTF-8 in the SimpleServlet ContentType prior to gettting
a Print Writer from the response object.
2. Updated ApplyXSLT to use default output properties for anything
that the stylesheet does not supply for setting the ContentType.
3. Updated ApplyXSLT to be able to use a default Templates object
when an xslURL parameter is not included in the request
and the XML source doc does not include a stylesheet PI.
Useful for cases where the same stylesheet is being used for
many/most transformations performed by the servlet.
Revision Changes Path
1.4 +6 -6 xml-xalan/java/samples/servlet/XSLTServletWithParams.java
Index: XSLTServletWithParams.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/servlet/XSLTServletWithParams.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSLTServletWithParams.java 2001/03/20 17:03:19 1.3
+++ XSLTServletWithParams.java 2001/04/23 18:53:37 1.4
@@ -96,10 +96,10 @@
HttpServletResponse response)
throws ServletException, IOException
{
- // Output goes in the response stream.
- PrintWriter out = new PrintWriter (response.getOutputStream());
- // This servlet is intended to return HTML.
- response.setContentType("text/html");
+ // The servlet returns HTML; charset is UTF8.
+ // See ApplyXSLT.getContentType() to get output properties from <xsl:output>.
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
@@ -126,7 +126,8 @@
{
transformer = tFactory.newTransformer(xslSource);
setParameters(transformer, request); // Set stylesheet params.
- transformer.transform(xmlSource, new StreamResult(out)); // Perform the transformation.
+ // Perform the transformation.
+ transformer.transform(xmlSource, new StreamResult(out));
}
else
out.write("No Stylesheet!");
@@ -136,7 +137,6 @@
}
catch (Exception e)
{
- out.write(e.getMessage());
e.printStackTrace(out);
}
out.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org