• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I used XML tag inside Servlets?

 
Eric Pramono
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm new to Servlets..
Could anyone please let me know whether I can use XML tag inside Servlets, instead of HTML tag?
Any reference to more detail information on this are highly appreciated.
Thanks in advance.
- eric
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless I am missing the pont of your question, yes, I believe you can use XML tags instead of HTML.
I am assuming that you want to use the output stream of a servlet to generate a page consisting of XML tagts? Basically the servlet just writes out whatever you tell it to and it is up to the browser to inerperet it. So, if the browser or some other appliation understands your XML tags you should be all set.
 
Ashwin Asani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do want to output XML from your servlet then you must first sent the content type to text/xml:
response.setContentType("text/xml");
After that you can give a wel-formed/valid xml output.
By default the content type is text/html.
So if you do not change that and you try to give xml output, the browers displays that it can understand as text or html. The browser will ignore the rest of the content.
 
Wayne Hefner
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can have the output stream generate any type of valid output, just be sure to set the appropriate content type. For xml the content type is text/xml
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I really should have included the information about the content type in my original response. Thanks guys.
 
Eric Pramono
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone..
that really helps.
- eric
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!