aspose file tools*
The moose likes Servlets and the fly likes URLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URLConnection" Watch "URLConnection" New topic
Author

URLConnection

Jonathan Cone
Greenhorn

Joined: May 22, 2005
Posts: 24
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: May 22, 2005
Posts: 24
Bill,

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

-Jon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLConnection