This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes XML & JSP Technology Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "XML & JSP Technology" Watch "XML & JSP Technology" New topic

XML & JSP Technology

Satya Srini

Joined: Feb 27, 2001
Posts: 4
Does anyone know how to send the results back from the JSP in form of an XML document.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12756
A JSP page can be written entirely as XML - after all there is little difference between HTML and XML formatting.
So just do it.
author of:
Scott Stirling

Joined: Mar 05, 2001
Posts: 24
The form of a JSP can be pure XML because the JSP spec specifies a standard translation of JSP syntax to XML (good if your JSP container supports it), but the output of a JSP is completely separate. I.e., a JSP can ouput plain text, HTML, XHTML, an applet, more XML, etc. I think the user is asking about outputting XML from JSP, not authoring JSPs in XML.
To get XML output, make sure you format any static template data in the JSP as well-formed XML. Then at the top of the JSP set the MIME type as XML, for example (using the default charset):
<%@ page contentType="text/xml;charset=ISO-8859-1" %>

Scott Stirling<BR>Author of <A HREF="" TARGET=_blank rel="nofollow">Java Server Pages Application Development</A>
I agree. Here's the link:
subject: XML & JSP Technology
Similar Threads
parse xml
jsp always an xml
browser returning error
How can I set bean property in JSF page?!
Well Formed