Writing Files to URLs

Reply

Join Date: Jun 2005
Posts: 7
Reputation: deineMutti is an unknown quantity at this point 
Solved Threads: 0
deineMutti deineMutti is offline Offline
Newbie Poster

Writing Files to URLs

 
0
  #1
Sep 14th, 2005
Hola,

I'm working on a personal-organizer applet and I'm having trouble saving my to-do lists. I want to save a vector that contains my table data as an object (don't feel like playing with text) and I'd like to save to the folder in my webspace where all of the applet files are (.class's, index.html, etc.).

At first I was getting "access denied" exceptions thrown at me, so I signed my .jar file. I then managed to figure out that I could use the <url>.openStream() method to load and also the URLconnection to get an output stream and now the load is working, but the save is not. It doesn't throw any exceptions or say that I'm doing anything wrong, but alas new items aren't being saved.

My save function:

  1. public static void saveDataURL(URL u)
  2. {
  3. URLconnection urlCon= u.openConnection();
  4. urlCon.setDoOutput(true);
  5. urlCon.connect();
  6.  
  7. OutputStream fout = urlCon.getOutputStream();
  8. ObjectOutputStream oos = new ObjectOutputStream(fout);
  9.  
  10. oos.writeObject(<vector of data>);
  11.  
  12. oos.close();
  13. }

I think the problem might have to do with the way I'm using an OutputStream instead of a FileOutputSteam as the argument when instantiating the ObjectOutputStream, but I could be wrong. (I modified this method to use URLS. When I was writing to the the local hard drive, I created a FileOutputStream from a File...)

I also tried something like

  1. ...
  2. FileOutputStream fout = (FileOutputStream) urlCon.getOutputStream();
  3. ObjectOutputStream oos = new ObjectOutputStream(fout);

...but I believe the compiler didn't think that was too bright of an idea.

Any help would be appreciated. Any speed in replying would also be appreciated. I've had my applet working for quite some time, but I can't use it yet and am beginning to become frustrated.

Thanks.
George.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Writing Files to URLs

 
0
  #2
Sep 15th, 2005
You almost certainly do not have write permission to the remote location.
And if you do have write permission there's an extremely serious security hole in your server which allows any cracker to come in and take over at any time.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Writing Files to URLs

 
0
  #3
Sep 15th, 2005
Maybe if the URL is running a server that accepts connections from a certain port that might be possible.
--
dein vater
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 7
Reputation: deineMutti is an unknown quantity at this point 
Solved Threads: 0
deineMutti deineMutti is offline Offline
Newbie Poster

Re: Writing Files to URLs

 
0
  #4
Sep 15th, 2005
Thanks for the replies guys, but here's the thing: I don't know very much about the backend side of things. I'd like to store my saved information in a central location so that I can use my applet everywhere. I thought storing a file in the same location where the applet itself is located was logical and that there'd have to be a way to write to this location.

This seems like a relatively basic goal, so there HAS to be a simple way to do this.

All I want to do is read/write an object (A vector) from/to a file on the server where my applet is stored.

Can it be done? (yes) If so, how?

Pretty Please...with sugar on top.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Writing Files to URLs

 
0
  #5
Sep 16th, 2005
Hi everyone,

I have some experience on this. You see usually when you are writing to a URL it most definately requires a username and password before you can write to that server.

You see some hosts when you want to use their site they require you to use their own uploading program as their are not using the RFC and using something custom.

But for argument sake let's assume that your host conforms to the RFC.
Now you will need to use the Authenticator class that will allow you to authenticate to you site and save your program there.

But not all servers do this and some of them put the password and username as part of the URL as such

  1. http://username:password@http.fileplanet.com/polo.zip

When you put this address in the URL class you will be able to connect.

A good example is ftp servers as a lot of them use this format wherethe username and password is part of the URL

Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Writing Files to URLs

 
0
  #6
Sep 16th, 2005
Hi everyone,

I noticed that you said that you were using an applet. I think that this may cause some security restrictions. If i were you i would prefer to do it as an application where there are practically no restrictions

Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Writing Files to URLs

 
0
  #7
Sep 20th, 2005
Hi everyone,

Did it work??

Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC