Hi guys,
I might be new to jsp.. but i was trying to read an xml file through jsp and it doesn't show anything when i open it..can someone help me figure out whats wrong with it?? or is there anything that i missed?
Thanks in advance.

here's a bit of my code:

<%@ page language="java" contentType="text/html" %>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="javax.xml.transform.*"%>
<%@ page import="javax.xml.transform.stream.*"%>
<%@ page import="countrylist.*"%>
<%@ page import="java.io.*" %>


try {
 		 // Load StreamSource objects with XML and XSLT files
		StreamSource xmlSource = new StreamSource( new File("country.xml") );
 		StreamSource xsltSource = new StreamSource( new File("country.xsl") );
		 // Create a StreamResult pointing to the output file 
		PrintWriter sout = new PrintWriter( out );
     	StreamResult fileResult = new StreamResult(sout);
 		// Load a Transformer object and perform the transformation
		TransformerFactory tfFactory =
      	Transformer tf = tfFactory.newTransformer(xsltSource);
       	tf.transform(xmlSource, fileResult);
  	catch (Exception e) { e.printStackTrace(); }    



Edited by bonethirst: typo

7 Years
Discussion Span
Last Post by peter_budo

1. What is purpose of reading xml if this can be simple showed in browser?
2. Why you doing this stuff in JSP if XML loading should be executed in servlet to handle any possible exceptions?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.