• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to send xml file to a different web server

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I my app I generate a xml document and write it to the output stream. But what I need to do is redirect the stream to a different server which will process the document for the user. How do I get this to work?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest that what you want to do is invoke a Web Service on the other server and then process the response for the user after it comes back.

Kyle
 
Pete Neu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thanks for the fast answer. The other programmer uses PHP and does not want a Web Service. He wants the document in the redirected response. Any chance to do it like this?
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so the basic problem (as I understand it) is that you can't BOTH write to an output stream from a servlet and use sendRedirect to redirect the URI to a different server. So what you will have to do is:

(1) Build your xml document as a String.
(2) Use an HTTPURLConnection to open a connection to the PHP program and send the String you just built.
(3) Get a String back from the HTTPURLConnection and then place that on the output of your servlet.

By the way -- might I say that this is a horrible architecture for your web site. This will work, but the response time may not be good. If your servlet is the one that the user hits from their URL, then it should be doing the processing -- it may be in your interest to write your own code to just redo everything the PHP program does.

Kyle
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic