• Post Reply Bookmark Topic Watch Topic
  • New Topic

sending data to servlets running in a different server  RSS feed

 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have two applications(WebApplications) running on two different servers.

I want one of my servlet in my application send an xml file to a servlet in other application(running on a different machine).

i can achieve this thing with a POJO having main(String args[]), using some
URL()...stuff..Its working perfectly.

Now i want to connect to that servlet from my servlet. (remember both servlets belong to different applications running on different systems)

I will be very grateful if someone can tell me how to achieve this thing.

Thanks&Regards
Ashok
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
To the best of my knowledge i dont know something in the servlet API that should do this stuff. Since you need to send an xml file you can post that file to the url (i.e other servlets url)as if you are uploading a file.
There is nothing in the servlet api to do this. You will have to use something you used in the stand alone java application.
Also apache commons project has the file uploading api, you can use that.

Check this.
http://commons.apache.org/fileupload/using.html

Hope thats helps your cause.

Cheers
 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amol,
Its not a problem of UPLOADING..the other servlet gets this XML file and converts it into a PDF file and returns it to my servlet...

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP file upload is certainly one way of transferring a file from one machine to another. You could also transport the contents of the file in the body of an HTTP POST request.
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya ulf is right,


Hi Amol,
Its not a problem of UPLOADING..the other servlet gets this XML file and converts it into a PDF file and returns it to my servlet...


Ashok, You need to do transformation using xslt, jasper or any other means, or use it for some other purpose that hardly matters and has nothing to do with file uploading. What i suggested is a way to send the xml file from one servlet, to other to do the transformation you need the xml file.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ulf suggested ,why not simply send the XML in the body of a HTTP POST request to the other servlet.
You can use Apache's HTTP-Client or URLConnection of core java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!