File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Http response containing XML document

P Jain
Ranch Hand

Joined: Jul 31, 2004
Posts: 52
Hi,

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
Greenhorn

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

Joined: Jan 10, 2002
Posts: 60975
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
Hi,

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

SERVLET RESPONSE:
response.setContentType("text/xml;charset=ISO-8859-1");
// Print the XML in the response object.

NOTE:
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="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Http response containing XML document