O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing Files and Data from an Applet

Without using any special security features, an applet can't access files on a local machine. It can, however, access files on the Web server using a number of different techniques. For example, you can use FTP to access the Web server, possibly using the FTPSession class from Chapter 28, "Overview of Internet Protocols." You can also create a custom socket protocol for fetching and storing files. The easiest technique, however, is to use the HttpURLConnection class for file access.

Retrieving Files

Using the URL and URLConnection classes, you can retrieve files directly from the Web server. The advantage of this technique is that you don't need to write any special code on the server side. Essentially, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required