public Document outputXMLonHTTP(String httpRequestType, URL url,
			   Document docToOutput) throws ProtocolException, IOException,
			   JDOMException {
			  XMLOutputter outputter = new XMLOutputter();

			  HttpURLConnection con = (HttpURLConnection) url.openConnection();
			  con.setRequestMethod(httpRequestType);
			  con.setDoOutput(true);
			  con.setDoInput(true);
			  con.connect();

			  outputter.output(docToOutput, con.getOutputStream());

			  Document responseDocument = null;

			  try {
			   SAXBuilder builder = new SAXBuilder();
			   responseDocument = builder.build((InputStream) con.getContent());
			  } catch (Exception e) {
			  }

			  if (con.getResponseCode() != 200) {
			   System.out.print("An network error occurred: "
			     + con.getResponseCode() + " - " + con.getResponseMessage());
			  }

			  con.disconnect();

			  return responseDocument;
			 }