[jdom-interest] Problems Creating a Document

Godbey, David DAVID.J.GODBEY at saic.com
Thu Nov 29 10:04:33 PST 2001


HttpURLConnection.getContentType. 

Hmm, what else? 
1. If the submitter sent UTF on the DataStream and you are reading regular
chars instead of UTF, you will have a problem due to the length bytes in
front of the string. 

2. Try trimming the string before feeding it to the parser. 

Hope this helps,
Dave


-----Original Message-----
From: Hunter Hillegas [mailto:timebomb at west.net]
Sent: Thursday, November 29, 2001 11:54 AM
To: Godbey, David
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Problems Creating a Document


Hmmmm... The output stream side is not controlled by me unfortunately, it is
controlled by UPS.

Any way for me to figure out what ContentType they are sending?

> From: "Godbey, David" <DAVID.J.GODBEY at saic.com>
> Date: Thu, 29 Nov 2001 08:12:35 -0500
> To: 'Hunter Hillegas' <timebomb at west.net>, jdom-interest at jdom.org
> Subject: RE: [jdom-interest] Problems Creating a Document
> 
> Hunter,
> I saw this error message just yesterday. I fixed it by adding on the
output
> stream side 
> resObj.setContentType("text/xml; encoding=UTF-8"); where resObj is
> instantiated from the HttpServletResponse class. I hope this helps.
> Dave
> 
> -----Original Message-----
> From: Hunter Hillegas [mailto:timebomb at west.net]
> Sent: Thursday, November 29, 2001 3:05 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Problems Creating a Document
> 
> 
> Hello. I am somewhat new to JDOM. I have used it several times for small
> projects but now I am trying to use it in a J2EE project and I'm having
some
> trouble...
> 
> Basically I am getting this exception:
> 
> org.jdom.JDOMException: Error on line 1: Document root element is missing.
> 
> This is how I'm setting up my JDOM session:
> 
> InputStream in = urlCon.getInputStream();
> SAXBuilder builder = new SAXBuilder();
> Document doc = builder.build(in);
> Element docRoot = doc.getRootElement(); //get the root
> 
> I have verified that the InputStream does seem to have access to valid XML
> that looks like this:
> 
> <?xml version="1.0"?>
> <RatingServiceSelectionResponse>
> <Response>
>   <TransactionReference>
>     <CustomerContext>Rating and Service</CustomerContext>
>     <XpciVersion>1.0001</XpciVersion>
>   </TransactionReference>
>   <ResponseStatusCode>1</ResponseStatusCode>
>   <ResponseStatusDescription>Success</ResponseStatusDescription>
> </Response>
> <RatedShipment>
>   <Service>
>     <Code>01</Code>
>   </Service>
>   <BillingWeight>
>     <UnitOfMeasurement>
>       <Code>LBS</Code>
>     </UnitOfMeasurement>
>     <Weight>2.0</Weight>
>   </BillingWeight>
> ... There is a lot more...
> 
> I'm trying to use this to communicate with UPS to get shipping info...
> 
> So, I have pretty much no idea how to debug this... Any suggestions are
> appreciated.
> 
> Hunter
> 
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t.com
> 



More information about the jdom-interest mailing list