File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes ftp or http or what? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ftp or http or what?" Watch "ftp or http or what?" New topic

ftp or http or what?

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
I'm trying to figure out which technology to use. Here's what I need to do:
Currently, my boss goes to a website that displays a login form, and eventually he clicks his way to a listing of URLs to data files that need to be downloaded. This other company posting the information uses servlets to retrieve the data and construct these files dynamically (as far as I can tell). We're going to get much more data in, so I need to automate this process.
I initially assumed I would need to try to open an FTP connection to their site in Java, so I was looking at the Apache Commons Net package. I assume that then I'd have to post the initial forms (login, etc) in Java, and then parse the listing page to find the live URLs to the files. However, I don't want to do this (e.g. learn the Apache Commons Net API) if there's a simpler way. For instance, should I be able to use classes like HttpURLConnection in the API to do all of my interaction with their site? All I know is that when I access their site, it's an https connection. If it's not as easy to use stuff that Sun provides, then by all means I'll try to do it with the Apache package.
Jerry Kreps gave me some advice in another post, but I don't want to start coding with that if my approach is not right!
Thanks for any advice,
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
HTTPS with URL is as simple as the lines marked as added a year ago:

You'll probably have to POST a form to log in. I haven't had great luck with sending POST data through URL. My last try in a JUnit test seemed to be sending everything twice. This was straight from a tutorial someplace on the web.

Hope some of that helps.
[ August 07, 2003: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: ftp or http or what?
jQuery in Action, 3rd edition