Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSPs as XML documents, but no HTML rendered!

 
Adrian Enns
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adrian Enns
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic