Is it possible to access HTTP files in a Java App (not applet)? What
about if the website is secure (i.e. requires a password) but I have
the password/login? What about in cases where the file must be chosen
from a dropdown list?
Is this the list to post this type of question to?
Thanks in advance,
--Uri
Simon OUALID - 15 Jun 2005 18:28 GMT
> Is it possible to access HTTP files in a Java App (not applet)? What
> about if the website is secure (i.e. requires a password) but I have
> the password/login? What about in cases where the file must be chosen
> from a dropdown list?
All is done by the URL class.
http://java.sun.com/j2se/1.5.0/docs/api/java/net/URL.html
URL url = new URL(myURLString);
InputStream is = url.openConnection().getInputStream();
Then use it as a normal stream, by associating it to a FileOutputStream
if you want to download the file on the file system.
I think (but I'm not sure) that HTTPS connection are handled by this
class. If you need authentification, you can ovveride the Authenticator
class and the getPasswordAuthentication() method.
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Authenticator.html
Symon
uri - 22 Jun 2005 16:36 GMT
Thanks Symon, I'm looking into the URL class, looks great.
Roedy Green - 26 Jun 2005 09:09 GMT
>Thanks Symon, I'm looking into the URL class, looks great.
see http://mindprod.com/jgloss/cgi.html
http://mindprod.com/jgloss/urlconnection.html

Signature
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
enrique - 15 Jun 2005 21:07 GMT
I guess so. When accessing a remote file with HTTP, that doesn't seem
different from what a browser would do, right? So design your Java App
to behave like a browser, when it needs to interact with the website.