File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Holy SPANK!!  I got a connection... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Holy SPANK!!  I got a connection..." Watch "Holy SPANK!!  I got a connection..." New topic
Author

Holy SPANK!! I got a connection...

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Well good news, I am halfway there. I can connect to my server and read from a file there. Here is the code I used:

I run this and get the correct data back from the file.
However what I need to do is update the file after the applet starts to keep track of how many times it has been run.
I found this code (both snippets) on the net as a tutorial and adapted it to my environment.
The code below is what allows you to connect to a server and write data. However I get a FileNotFoundException when running this part:

Any clues...also the whole InputStream section of code, I don't understand what its there for.
Thanx
Ryan Headley
[This message has been edited by ryan headley (edited January 31, 2001).]


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Ryan,
Read this document ( http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html ) on the Sun website about reading and writing to URLs... Basically you can read a file (which is what http is made for), but you cannot write a file... you can only write to the URL for some kind of server-side program like a cgi-script to interpret... If you ask why you cannot do this, think on this : If you could write files directly to the server you could overwrite (or erase) any webpage...
The only way you can write anything to the server is to write a program that runs on the server and have your program call it... either with CGI or via Sockets...
Anyway, HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Thanx for your input. At least you answered. I'd had asked questions similar to this already and was lead to believe it was possible, (with things like signed applets etc.)
I guess I'll just hang it up for now. I don't think my ISP supports jsp or servlets, or if they do, they don't have information on setting up a page with it.
Guess I'll wait to get DSL and my own .com and mess with it that way.
Thanx again.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

First, of all your classes are not Applets. To be an Applet, your class must extend Applet, and have a method public void init().
Second, maybe you can use signed Applets but I dont know much about them(except that the client can choose not to accept). I think you have to pay to have it signed.
[This message has been edited by Randall Twede (edited February 04, 2001).]


SCJP
Visit my download page
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
yeah, that code that I posted, was after I had converted it from an applet to an app.
Sorry about that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Holy SPANK!! I got a connection...