Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLConnection

 
Jonathan Cone
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gang,

I'm working on a web application in which I would like a servlet to connect to a 3rd party website and download a file into my webapp context. What I need help with is a game plan because there are some things I am unsure about:

1) I see that I should use a URLConnection object to do the brunt of the work.
2) Am I going to need two URLConnection objects since I need to log in first - or rather does one persist across two requests (does this even qualify as two requests)?
3) What's the best way to validate if the login was successful so I know if I can move on to the file download?

Any advice is always appreciated.

Thanks,
Jon
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you will find the HTTPclient toolkit to be very helpful. It will maintain any cookies needed over multiple requests, and help with response handling. No need to reinvent the wheel!

Bill
 
Jonathan Cone
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,

As I'm looking over HttpClient, I can see that its exactly what I was looking for - thanks!

-Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic