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, ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.