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>