This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Return XML/HTTP frm a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Return XML/HTTP frm a servlet" Watch "Return XML/HTTP frm a servlet" New topic

Return XML/HTTP frm a servlet

Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
I want to design a servlet which will will be invoked from an application residing in a different web server and the second application will get back an XML blob as a return.
The whole connection will be based on HTTP ofcourse(no SOAP etc).
Any suggestions on how to achieve this?

Thanks in advance,
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
It seems like you have answered your own question almost.

1. Servlet gets invoked with request
2. Build relevant XML
3. Get response output stream
4. Write content type
5. Dump XML
6. Profit!

Do you have a more specific question?

I'd recommend reading this servlet tutorial.

This code might be a very simple example of what you want. It doen't do any error checking and I make no guarantees to it's correctness!

It is sorta covered in the JavaRanch Style Guide.
subject: Return XML/HTTP frm a servlet
Similar Threads
JAX-RS : A Way to Serialize String to XML as a Response?
Configure to include servlet problem
Passing array from servlet to java
Servlet not displayed when called from browser - XML configuration problem?
GUI client talk to servlet