This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am currently trying to do an application that does the upload as well the download of files from a http server that needs authentication. The thing is i am not very sure where to begin and i am open to any suggestions.
Basically what i am trying to upload is a html file onto the http server and also have the capability to download back that file back to my computer if i need it. The server i am using does not support ftp so using the sun's ftp classes are out but i am not sure if there are classes that exist for the uploading and downloading of files from a http server.
I am not using servlets but trying to upload or download a simple html file to http server from a java application
Sample codings as well as informative links would be helpfull
I am basically trying to upload a html file or download a html file to or from a http address. The thing is that i have been reading up on some http and it seems that i can use the URLConnection class to get the output or input stream from that http address but the thing is it does not say how do i authenticate(ie. username and password) before i can connect to that particular http server. Do you know how this can be achieved??
Thank for your links as they were extremely helpful
From what you are saying this is what i understand say for example if my username w and password is w1 so to use the class this what i would have to do
My problem is now when do i know when i need to authenticate. I do not know if the class con which i have above which sets the default authenticator is correct before i try to connect to that URL and get its stream and would really appreciate some guidance from you.
I do not know if the class con which i have above which sets the default authenticator is correct before i try to connect to that URL and get its stream
Change the lines
and you're set. Have a look at this example. Not much different from what you have. The method getPasswordAuthentication() gets invoked when URL tries to access the protected URL. Either you hard-code the username and password in the Authenticator or you prompt the user at that time for the values.
Joined: Jan 07, 2005
From what i get is that the Authenticator class takes care of all the authentication needs so i do not have to to worry about about encoding my user name and password with BASE64 alogrithom and pass it to the server as the Authenticator class takes care of all of this.