aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP document (XML syntax) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP document (XML syntax)" Watch "JSP document (XML syntax)" New topic
Author

JSP document (XML syntax)

Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Hi all,

I have create a simple JSP document

<html xmlns:jsp="http://java.sun.com/JSP/Page">
<head>
<title>Hello World</title>
</head>
<body>
<jsp:scriptlet> out.println("Hello World !"); </jsp:scriptlet>
</body>
</html>

Difficult to make easier

The output on my browser is viewed as an xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<html>
<head>
<title>Hello World</title>
</head>
<body>Hello World !</body>
</html>

I am quite surprise because I expected to view only "Hello world" (as if it was an html document. I know that HTML do not respect always XML syntax but in this case it does....

As we can see the first line of the output is added by the container (<?xml version="1.0" encoding="UTF-8" ?> . This is why I do not see only "Hello World" on my web page but the code HTML.

I tought this line should be added manually in order to specify if we would like the output as an XML file or an HTML.

So my question is if there is any means to see my JSP document as an HTML page in my browser using XML syntax ?

If not this means we cannot make evrything we can with JSP syntax.

Thanks for having the patience to answer this question.
Tiggy
Sivasundaram Umapathy
Ranch Hand

Joined: Aug 10, 2002
Posts: 360
The container adds the xml declaration when you don't use jsp:root as the top element of your JSP document. You can control this behavior by using the jsputput action with the omit-xml-declaration property set to "yes" or "true"

So there are 2 solutions for your problem.
1. Use jsp:root
2. Use the jsputput as

<jsputput omit-xml-declaration="yes"/>


Siva
Co-Author - SCMAD Exam Guide - ISBN:9780070077881
Author - Java certification success, Part 4: SCEA
 
Consider Paul's rocket mass heater.
 
subject: JSP document (XML syntax)