File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP document (XML syntax)

 
Adri Smith
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 360
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic