aspose file tools*
The moose likes Servlets and the fly likes XML output shown as plain text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "XML output shown as plain text" Watch "XML output shown as plain text" New topic
Author

XML output shown as plain text

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
I have a servlet which build an XML document on the fly.

My problem is that the servlet shows the xml data as plain text. Instead I want it to show a the contentType text/xml.

I have tried to set the contentType in the servlet:
response.setContentType("text/xml; charset=ISO-8859-1");

- but it doesn�t help.

Here is where I create the output:



How can I set the contentType so the output is shown as text/xml?
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
It may just be me, but what do you mean when you say the servlet shows the data as plain text?
What are you outputting to?
A browser, a file, a console window.

Maybe if you provided a sample of the output?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

have you tried the content type without the encoding? ie "text/xml"
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Okay I don�t have the problem anymore. And I don�t know why, because I haven�t changed anything in the code. Strange! But thanks anyway.

"Yes I was outputting to the browser".
 
 
subject: XML output shown as plain text
 
Similar Threads
Problem with POST in ajax
XML & JSP Technology
View several XSL documents in one HTML page
maintain the format of xml message on browser
Turn XSLT into HTML content