Date: 2004-07-22T06:43:08
   Editor: CharlieHarvey <[EMAIL PROTECTED]>
   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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to