Hi all,

I'm working on an app where I need to exchange XML data between
Java Servlets. All of the examples/books/etc that I come across
focus almost exclusively on either JSP-to-Servlet (via a GET or
POST of form data) or outputing data from a Servlet to a JSP.
In my case, I need to be able to compose an XML document (from
withing either a JSP or a servlet), open a connection to my
servlet, push the data over & then listen for a response.
Basically, the code looks like this:
StringBuffer doc = new StringBuffer();
doc.append("<?xml version='1.0'?>");
doc.append("<mydoc>");
doc.append("<data>HelloWorld</data>");
doc.append("</mydoc>");

try {
String sUrl = new String("http://
[myDomain]/servlets/myXMLHandler");
URL purl = new URL(sUrl);
URLConnection urlc = purl.openConnection();
urlc.setDoOutput(true);
urlc.setDoInput(true);
urlc.setRequestProperty("Content-type","text/xml");

PrintWriter pw = new PrintWriter(new OutputStreamWriter
(urlc.getOutputStream()),true);

pw.write(doc + "\r\n");
pw.flush();
pw.close();

} catch (Exception e)
{
// log the error....
}

My question is: for the servlet that receives this document,
how, exactly does it extract the XML document from the stream of
incoming data? doGet() and doPost() would only seem to apply if
the data is being sent from a JSP with either a GET or POST. In
this case, wouldn't I just extend/override the service() method?
In that case, I'm obviously not using the getParameterX()
methods, since there are no parameters... is the XML document
embedded into the HTTP header?

Any assistance would be greatly appreciated!

Bala Paranj

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to