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.*" %>

<html>
<head>
<title>Country</title>
</head>
<body>

<%
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 =
		    TransformerFactory.newInstance();
      	Transformer tf = tfFactory.newTransformer(xsltSource);
       	tf.transform(xmlSource, fileResult);
       	
  	}
  	catch (Exception e) { e.printStackTrace(); }    

%>

</body>
</html>

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.