home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Sams Teach Yourself Visual J++ 6 in 21 Days
(Publisher: Macmillan Computer Publishing)
Author(s): Rick Leinecker
ISBN: 0672313510
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Making Applets Live

After you’ve created an applet, the chances are pretty good that you’ll want to make it available to the entire Web population. To do this, you must upload the various files that make up the applet to a Web site and test them, to make sure that nothing breaks in the process.

To upload applets to a Web site, you must have the authority and the tools (such as an ftp tool) to do so. If the site you want to add the applet to is maintained by someone other than yourself, you’ll have to obtain permission and perhaps even get the access passwords if you plan to upload the materials yourself. If you don’t already have such authority, you can give the applet and the various files it uses to someone who will eventually perform the upload.

Obtaining WS_FTP

My preference in tools for doing the file uploads is WS_FTP. It’s a great FTP tool that you can download from a Web site. The version that’s downloadable is a trial version. If you decide to continue using it, you’re expected to buy the full version.

To get a copy of WS_FTP, go to the Ipswitch Web site at http://www.abraxis.com/ipswitch/Default.htm. Besides getting the trial version, you’ll be able to check out Ipswitch’s entire line of products.

For the remainder of this chapter, the FTP program we’ll use is WS_FTP. Before going any further, you might want to download the program and install it on your system.

Creating the Web Server Directory Layout

If this is the first time Java is being used at a site, it might be a good idea to create a directory structure that will contain the Java classes and other associated files such as audio and graphics files. This is pretty straightforward and will be similar to how the directory structure is set up on your local drive.

Make sure that you know in which directory the initial HTML file will be located. Many services require an index HTML file in a directory, and Web browsers that hit the site will automatically load this particular file. If your service has this requirement, you will probably want to place your Java files in this directory.

Connecting to the Server

If you have permission to upload files to a site on the Web, you’re ready to get started.

After WS_FTP32 is installed, run it. The Session Properties dialog box, shown in Figure 3.3, will appear on top of the main program window.


Figure 3.3  The first thing you see when you run WS_FTP is the Session Properties dialog box.

In this dialog box, you’ll enter information about the destination server, including its name (or IP address), your login name, and your password. If you have the Save Password and Auto Save Config check boxes selected, the information will be saved and you can log in by simply selecting the server from a list.

Fill in the Profile Name, Host Name, User ID, and Password fields. It’s a good idea to make the Profile Name and Host Name the same to avoid ambiguity. With the information correctly entered, click the OK button and the program will try to log on to the server.

The left list box of WS_FTP’s main window contains a listing of the current directory, even when you’re not logged on to a server. When logged in, you’ll see a directory listing in the list box on the right half of the screen, as shown in Figure 3.4. This shows only the names of the files and directories, not file and directory details. To get a listing of full file and directory information, click DirInfo in the right column of buttons.


Figure 3.4  The right list box contains a directory listing of the server to which you logged on.

You’ll have to know how to find your directory on the server. Many ISPs have a directory structure that will make it hard to find your directory. Make sure that you have the documentation for your account. Although it might be cryptic (as is usually the case), it’ll be your best bet of finding the directory. Other ISPs are more understanding and drop you right into your directory after you log on.

These are the steps for connecting to a server:

1.  Run WS_FTP (the Session Profile dialog box will appear).
2.  Enter information about the server such as the server name (or IP address), your login name, and your password.
3.  Click the OK button and wait for WS_FTP to connect to the server.
4.  In the list box on the left side of the WS_FTP window, navigate to the local directory you want to transfer from.
5.  In the list box on the right side of the WS_FTP window, navigate to the server directory you want to transfer to.
6.  Highlight the files you want to transfer and click the -> button.

Uploading the Applet

After you’re connected, you can upload the files. I’ll use a HelloWorld applet as an example. You must upload HelloWorld.class and HelloWorld.html. Not all three of these files (the HelloWorld.html, HelloWorld.class, and HelloWorld.java files) are necessary to run the Java program—only HelloWorld.class is required. You can upload HelloWorld.java if you want to offer the source code for download. Our example here will assume that you’re uploading the .java source code so that users can download it.

The HelloWorld.html file is the HTML file that J++ created with some additional lines so that users can download the source code. Later in the chapter, we’ll talk about incorporating this code into another HTML file, but for simplicity you’ll use it as it was created and have your main HTML file upload HelloWorld.html.

Begin by navigating the left list box so that it shows all three HelloWorld files. Highlight them as shown in Figure 3.5 and then click the -> button.


Figure 3.5  Highlight the files you want to upload and click the -> button.

The files will be uploaded to the server. Because the files are short and most modem connections are pretty fast, you won’t see much more than a blink as the upload progress box appears during the upload. For longer files, the upload progress box will stay visible long enough for you to see it.


Caution:  Most FTP client programs, such as WS_FTP, automatically detect the type of file you’re uploading. For FTP uploads, a distinction is usually required between binary and text files. When a program automatically detects the file type, you don’t have to worry about it; the correct settings will be used for the transfer.

But some FTP client programs might not have an automatic detection feature. If this is the case, you’ll have to specify text for HTML files, and binary for .class files.



Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.