Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Holy SPANK!! I got a connection...

 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4390
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, that code that I posted, was after I had converted it from an applet to an app.
Sorry about that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic