This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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>
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
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Jun 28, 2000
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.
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).]