Subject: servlet and xml From: jayadeva@xxxxxxxxxx (Jayadeva Babu Gali) Date: Wed, 24 Mar 1999 18:10:13 +0530 |
I am trying to dynamically creating an XML document with the Java Servlet and i am trying to style that XML information to the browser(IE5) using the static xsl document in the same directory where the servlet is there when i am trying to execute that servlet it is giving error like this Access is denied. Error processing resource 'file://c:\servlets\test.xsl'. i am developing an xml application for that it is necessary to disply the xml document on the fly with static xsl. i am attaching my servlet and xsl file can u please co-operate me regds...jayadev
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /* * test Servlet sends back a simple, static XML page. */ public class test extends HttpServlet { public void doGet ( HttpServletRequest req, // This provides information sent by the browser HttpServletResponse res // This is used to send information back to the browser ) throws ServletException, // General exception that should be thrown if there // is a unrecoverable error in the Servlet IOException { // Set the MIME type for the information being sent to the browser. // In this case, we are going to send back HTML res.setContentType( "text/xml" ); // Get a reference to the output stream. // Anything written to this stream is sent directly to the browser // (The browser sees this as its input). ServletOutputStream out = res.getOutputStream(); // The following println statements create an HTML page. // Notice that the <html></html>, <head></head>, and <body></body> // tags are all properly formed HTML syntax. out.println("<?xml version=\"1.0\"?>" ); out.println("<?xml:stylesheet type=\"text/xsl\" href=\"file:///c:/servlets/test.xsl\"?>"); out.println("<persons>"); out.println("<person><firstname>Oren</firstname><lastname>Ben-KiKi</lastname></person>"); out.println("</persons>"); } }
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns=""> <xsl:template match="/"> <HTML> <HEAD> <TITLE>Test</TITLE> </HEAD> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="*"> <xsl:apply-templates/> </xsl:template> <xsl:template match="persons"> <xsl:for-each select="person[1]"> <h1><xsl:value-of select="firstname"/></h1> <h1><xsl:value-of select="lastname"/></h1> </xsl:for-each> </xsl:template> <xsl:template match="textnode()"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Outputting to separate files., Alan Kennedy | Thread | Re: servlet and xml, Simon St.Laurent |
Re: Sorting and Filtering Data, Steve Weyer | Date | Re: template matching.. display the, Andrew McNaughton |
Month |