wood burning stoves*
The moose likes JSP and the fly likes JSPs as XML documents, but no HTML rendered! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSPs as XML documents, but no HTML rendered!" Watch "JSPs as XML documents, but no HTML rendered!" New topic
Author

JSPs as XML documents, but no HTML rendered!

Adrian Enns
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
I am using Tomcat 5.5 and trying to run a simple JSP using the XML syntax. When I call the JSP page no error occurs, but the output of the page appears as XML in the browser... whereas I really want it to render HTML. Do I need to do something to make the page render HTML? The code for my page is below:

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:text>
<html>
<head><title>Simple JSP as XML</title></head>
<body>
<h1>Hello World!</h1>
</body>
</html>
</jsp:text>
</jsp:root>
[ May 11, 2005: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

trying to run a simple JSP using the XML syntax


Why? The XML syntax (termed "JSP Documents") isn't well suited to hand-coding but is intended for machine-generated pages.

That said, your container is obviously not recognizing the page as JSP and is sending it uninterpreted to the browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adrian Enns
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
I figured it out. Had to use the following directive to explicitly state that the page should be rendered as HTML:

<jsp irective.page contentType="text/html"/>
 
jQuery in Action, 2nd edition
 
subject: JSPs as XML documents, but no HTML rendered!