[jdom-interest] XML file in a servlet

Zach Hollandsworth zholland at quarem.com
Sun Nov 4 14:48:35 PST 2001


I have also tried "response.setContentType("text/xml");", but it is actually
HTML so I think it should be "text/html".

Zach

-----Original Message-----
From: Matthew MacKenzie [mailto:matt at xmlglobal.com]
Sent: Sunday, November 04, 2001 4:49 PM
To: zholland at quarem.com
Subject: RE: [jdom-interest] XML file in a servlet


Change the content type to text/xml.  What is happening is that the
browser thinks it is HTML.

Regards,

Matt

-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
On Behalf Of Zach Hollandsworth
Sent: November 4, 2001 2:33 PM
To: 'JDOM'
Subject: RE: [jdom-interest] XML file in a servlet


It performs as normal, when I go to view source in the browser, it is
all there.  But the browser is blank.  Which leads me to believe it is
content type or encoding related.

-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Matthew MacKenzie
Sent: Sunday, November 04, 2001 4:29 PM
To: 'JDOM'
Subject: RE: [jdom-interest] XML file in a servlet


...and what is the sporadic behaviour?  Do you get an exception?

-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
On Behalf Of Zach Hollandsworth
Sent: November 4, 2001 2:16 PM
To: 'JDOM'
Subject: RE: [jdom-interest] XML file in a servlet


Very simply, trying to get XmlFile.xml (well formed HTML as XML) out to
the browser.  I have try quite possibly hundreds of combinations of
charsets, and encoding types.  The file is quite large and has been run
through tidy. If I load the file straight through the browser, it works
fine.  But when run through this servlet, it does not.  In IE, it runs
and you can see it in the "view source", and it work more often in NN,
but I can't nail anything down for sure.

-------------------------------------------------
public void doGet(...
{
 try
 {
  response.setContentType("text/html; charset=UTF-8");
  PrintWriter writer = response.getWriter();

  org.jdom.input.SAXBuilder sb = new org.jdom.input.SAXBuilder();
  org.jdom.Document d = sb.build(new java.io.File("XmlFile.xml"));
  org.jdom.output.XMLOutputter xo = new org.jdom.output.XMLOutputter("",
false, "UTF-8");
  xo.setEncoding("UTF-8");
  xo.output(d, writer);
 }
 catch (org.jdom.JDOMException jde)
 {
  jde.printStackTrace(response.getWriter());
 }
}
-------------------------------------------------

Thanks in advance.
Zach Hollandsworth


-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Matthew MacKenzie
Sent: Sunday, November 04, 2001 4:04 PM
To: 'JDOM'
Subject: RE: [jdom-interest] XML file in a servlet


You need to elaborate upon this sporadic behaviour, maybe by including
your code and/or exceptions.

Regards,

Matt

-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
On Behalf Of Zach Hollandsworth
Sent: November 4, 2001 11:54 AM
To: 'JDOM'
Subject: [jdom-interest] XML file in a servlet


I realize that this is not fully a JDOM question, but it is close.  I
have been working on this for quite some time with no success.  I have a
strong feeling that it is some type of encoding issue.

What I am trying to do is simple,  Load an XML file from a file, and
display it via a servlet to the browser.

The behavior that I get is very sporadic.

Any suggestions?


Thanks

Zach Hollandsworth


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhos
t.com


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhos
t.com


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com





More information about the jdom-interest mailing list