Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

HTTP File Access with Java

Thread view: 
uri - 15 Jun 2005 17:38 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?

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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.