How to read in the XML file on a remote website using JSP? -


I am using java servlets and jsp in my application and I have to read the remote xml file and it should be read properly in html Have to present and display on a web page ... What techniques have been used to read the process? Should I use the HTTPURLConnection class to read the contents of the XML file or any other way? Moreover, if I use servlet as a controller and JSP, then what will be the responsibility of servlet and JSP in this process? Do you want to read the entire XML file completely and then send the output to read the JSP which will be printed now?

P>

JSP has no responsibility. Just change XLL in Xlett using XSL and write it directly for response to OutputStream .

  StreamSource xml = new streamsource (new url ("http: / .exe_file.xml") openStream ()); StreamSource xsl = New StreamSource (new file ("/ path / to / file.xsl")); StreamResult = new stream result (response.getOutputStream ()); Try {Transformer Transformer = Transformer Factor. New Instance () New transformer (xsl); Transformer. Transform (xml, out); } Grip (TransformerException E) {New Service Exception ("Transforming XML Failed.", E); } Do not forget to use  HttpServletResponse # setContentType ()  by using   

Content-type , otherwise the webbrower can handle it Is plain text


Comments