File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Http response containing XML document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Http response containing XML document" Watch "Http response containing XML document" New topic

Http response containing XML document

P Jain
Ranch Hand

Joined: Jul 31, 2004
Posts: 52

I am new to this group, I want to know that how do I send a response from server which contain XML document or a specific XML element(that contains other elements aslo).

P Jain

Regards<br />P Jain
Khan Malamir

Joined: Sep 09, 2005
Posts: 16
JSP response can contain whatever you like, it is not limited to HTML.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Well, since this is the servlets forum, I'd say that the servlet output can contain any data that the author would like.

If you want the response to be treated as XML on the client, be sure to set the content type header to "text/xml".

[Asking smart questions] [About Bear] [Books by Bear]
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121

<%@ page contentType="text/xml;charset=ISO-8859-1"%>
// Write the XML in JSP file.

// Print the XML in the response object.

1. Both the above approaches display the XML in the browser.
2. You can even generate dynamic content (say, bring data from backend and display in XML), the way you do normally.
3. If you want the XML to download as a document, you would have to send it as a response attachment.

keep smilin :: sravan<br /><a href="" target="_blank" rel="nofollow">I scribble here</a>
I agree. Here's the link:
subject: Http response containing XML document
jQuery in Action, 3rd edition