alegria alegria - 23 days ago 10
Java Question

XML code doesnt seem to work in JSP code on eclipse browser

My problem is as I stated above. Couldn't find any solution worked for me nor the existing ones weren't specific enough to fit in my situation. Here's the detailed explanation:

I am using the Eclipse Indigo Java EE IDE on Windows 8 machine, trying to learn JSP and the web services environment by the tutorial "Up and Running with Java Applications" by Todd Perkins, using the built-in Tomcat v7 server in eclipse and mysql & apache from Xampp. I've taken the baby steps as instructed and saw it working in the built-in browser in eclipse. But when it comes to execute the following line

<?xml version="1.0"?>

<world>
<%
Connection conn = null;
Statement stmt = null;
ResultSet result = null;

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/world","root","1234");
out.println("Connected to database.");

}catch(SQLException ex)
{
out.println("Error connecting database");
}
%>
</world>


it just gives this screen.

For clarification,

The xml tag world is the name of the database i'm using.
I omitted the heading directives from code.

Thank you all in advance for any suggestions. Any link to a similar problem that I overlooked is welcomed.

Answer

It looks to me like it'd doing exactly what you're telling it to do.

It's printing the xml tag, and then inside that tag, either an error message, or a successful message, in the same format you specified, what exactly are you expecting it to do?

If you're expecting the output that just has the word, maybe it'd be because your browser isn't displaying XML the same way as the instructors, could you post the entirety of your xml so we can see it?