This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet: attempts to access file from its originating server

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet that
1) reads an address from a textbox(on a user's screen)
2) matches the address against a simple .txt file on the applet's server.
I've been trying to use RandomAccessFile("address.txt"), but
I have been getting security errors...
Please answer these questions for me:
1) True/False An applet has automatic access to any file in the directory from which it orginated (ie my website's server).
2) True/False You must use a URL object to connect the applet to its server.(in order to enable data transfer to the applet).
3) How do I tell the applet where the text file is (ie do i use ""..)
Any help plus hints and suggestions would be much appreciated. I
am fairly new to java...
Saloon Keeper
Posts: 22287
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. False. A web server isn't a file server. You can't just call open() on it, and what would you use for a drive ID, anyway?
2. No. You could always roll your own connection with sockets.
3. Because of 1, above, this isn't meaningful.
What you'd actually do is place the file in one of the folders of the web server just like it was HTML. If it's a text file, your web server will normally serve it up (unless someone's changed the default configuration to something weird). You'll be able to see this by just typing in the URL for the text file, and watching it display in your browser. That's NOT a "file", however, it's a data stream loaded FROM the copy of the file on the server, and the semantic difference is important - there are HTTP headers and other things also coming down the pipe, and, as I've said, you can'd call your local open() function to make an HTTP request.
In Java, the easiest way for an applet to retrieve the contents of a server-provided file is to create a URLConnection and open an input stream on it. What you do after that depends on what your app intends to do with the data.
Right! We're on it! Let's get to work tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic