[jdom-interest] XMLOutputter not posting doc to OutputStream

Jason Hunter jhunter at servlets.com
Mon Sep 30 19:17:35 PDT 2002


I'd start by getting simple strings to go back and forth.  Odds are this
isn't JDOM related.

-jh-

Clif Bate wrote:
> 
> Hello,
>   This question may be rather basic to those more
> experienced, however I have not been able to work my
> way out of this.
>   I have a class that is building an XML doc using
> JDOM and then am trying to post it to a URL.  I have
> used the XMLOutputter to output the doc to the
> System.out to verify the doc is correct, and it is.
> 
>   However, when then trying to post it to a URL it
> does not seem to be sending anything.  I have an the
> receiver set to email me the data received.
> 
> Here is the code snipplets:
> 
>     private XMLOutputter oOutputter = new
> XMLOutputter("  ", true);
> oOutputter.output(p_oDoc, System.out); // this works
> 
> HttpURLConnection conn = (HttpURLConnection)
>                url.openConnection();
> conn.setDoInput(true);
> conn.setDoOutput(true);
> conn.setRequestMethod("POST");
> conn.setRequestProperty("Content-Type", "text/xml");
> conn.setUseCaches(false);
> OutputStream out = conn.getOutputStream();
> InputStream in = conn.getInputStream();
> 
> oOutputter.output(p_oDoc, out);
> out.flush();
> out.close();
> 
> // Read the response
> Document response = null;
>  try {
>        SAXBuilder parser = new SAXBuilder();
>        response = parser.build(in);
>        in.close();
>        conn.disconnect();
>     } catch (IOException ioe) {
>             logger.debug("Error reading the response
> document: " + ioe);
>          } catch (JDOMException jde) {
>             logger.debug("Error building the response
> document: " + jde);
>          }
> 
> I am successfully getting a reply from where I am
> posting to, and able read the XML in the response.
> Its just that it tells me that nothing was received at
> the URL.
> 
> Any help would be greatly appreciated.
> 
> Thanks,
> Clif
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list