You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ve...@jakarta.apache.org on 2004/07/22 15:43:08 UTC
[Jakarta-Velocity Wiki] Updated: DVSLExamples
Date: 2004-07-22T06:43:08
Editor: CharlieHarvey <ch...@alloy.com>
Wiki: Jakarta-Velocity Wiki
Page: DVSLExamples
URL: http://wiki.apache.org/jakarta-velocity/DVSLExamples
Added more examples of how to use in a servlet/action
Change Log:
------------------------------------------------------------------------------
@@ -12,3 +12,32 @@
dvsl.transform(in, out);
out.flush();
}}}
+
+
+{{{
+String realPath = this.getServletContext().getRealPath( "/" );
+DVSL dvsl = new DVSL();
+String inFile = request.getParameter( "inFile" );
+String styleFile = request.getParameter( "styleFile" );
+dvsl.setStylesheet( realPath + styleFile );
+Reader in = new FileReader( realPath + inFile );
+Writer out = new BufferedWriter( response.getWriter() );
+dvsl.transform( in, out );
+out.flush();
+}}}
+
+
+{{{
+String realPath = this.getServletContext().getRealPath( "/" );
+DVSL dvsl = new DVSL();
+URL inURL = new URL( "http://www.server.com/weather.xml" );
+String styleFile = request.getParameter( "styleFile" );
+dvsl.setStylesheet( realPath + styleFile );
+URLConnection uConnection = inURL.openConnection();
+uConnection.connect();
+InputStream is = uConnection.getInputStream();
+Writer out = new BufferedWriter( response.getWriter() );
+dvsl.transform( is, out );
+out.flush();
+}}}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org