This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Http response containing XML document  RSS feed

 
P Jain
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Khan Malamir
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP response can contain whatever you like, it is not limited to HTML.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!