Developer.com Logo Click here to support our advertisers
Click here to support our advertisers
SHOPPING
JOB BANK
CLASSIFIEDS
DIRECTORIES
REFERENCE
Online Library
LEARNING CENTER
JOURNAL
NEWS CENTRAL
DOWNLOADS
COMMUNITY
CALENDAR
ABOUT US

Journal:

Get the weekly email highlights from the most popular journal for developers!
Current issue
developer.com
developerdirect.com
htmlgoodies.com
javagoodies.com
jars.com
intranetjournal.com
javascripts.com

All Categories : Java

Chapter 3

Browsing Java

by Bryan Morgan and Michael Morrison


CONTENTS


Java applets wouldn't be very useful without a client Web browser to run them in. Sure, we could all download applets and run them using the JDK (Java Developers Kit) applet viewer tool but that wouldn't be quite the same. Because Java applets are so dependent on quality Java-enabled Web browsers, this entire chapter explores the available Web browsers that currently offer Java support. The three big browsers that support Java as of this writing are Sun's HotJava 1.0, Netscape Navigator 3.0, and Microsoft Internet Explorer 3.0.

The HotJava 1.0 browser is actually still in pre-beta form, but it will be an important browser in the near future because it is being developed by JavaSoft. The other two Web browsers, Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0, are currently battling it out over who dominates the Web client software market. This chapter doesn't bother trying to rate one browser over another because all we're concerned with is Java. Instead, you learn about what each browser has to offer in terms of Java support.

HotJava 1.0

The HotJava browser is a product of JavaSoft, the subsidiary of Sun Microsystems that is responsible for Java. It is the only Web browser that not only supports Java applets but also is actually written in Java. Although the browser market is dominated at the present time by Netscape Navigator and Microsoft Internet Explorer, HotJava stands a chance to rock the boat a little when it ships in final form.

What is now known as the HotJava product was actually introduced as a standalone Web browser back in the spring of 1995. As Java's potential was recognized by the public and its popularity skyrocketed, HotJava came to be much more than a Web browser. The HotJava product now also refers to a set of Java class libraries that simplify the creation of Internet-aware applications. The HotJava browser is provided as a showcase of these class libraries' capabilities. The HotJava class library will be available from JavaSoft as a licensable product in the near future, possibly at the release of Java 1.1.

At this time, HotJava can best be explored by downloading and installing the HotJava Web browser. You can download the HotJava browser from JavaSoft's Web site:

http://www.javasoft.com.

In the following sections, you learn about some of the features in HotJava that make it unique among other Web browsers.

HotJava Features

The HotJava Web browser supports many of the most popular browser features. More important to this discussion is its support for the execution of Java applets. HotJava also has the following features that make it somewhat unique among other browsers:

  • Security-Because HotJava was written using the Java language, it provides a very secure environment for Java applets to run in.
  • External Viewers-Although the HotJava browser will natively display a number of file formats such as HTML, GIF, and JPEG, its designers realized the need to occasionally view documents of other types. HotJava allows the user to configure viewers based on the file's MIME (Multipurpose Internet Mail Extensions) type.
  • Configurable User Interface-The HotJava user interface is completely contained within files included with the HotJava installation. These files can be changed or replaced, allowing users to completely modify the appearance of the HotJava browser.

Navigating in HotJava

Figure 3.1 shows the navigation buttons available to the HotJava user.

Figure 3.1: The HotJava navigator buttons.

These buttons, from left to right, perform the following functions:

  • Go back a page
  • Go forward a page
  • Go to home page
  • Reload a page
  • Stop a page's loading
  • Show HTML errors

The last button bears some special mention because this feature is unique to the HotJava Web browser. HotJava features a sophisticated HTML parser that can detect errors in HTML pages. The last button on the HotJava toolbar is used to display any HTML errors found within a page.

Setting Preferences

HotJava provides a means to alter its preferences, which means that you can configure the browser display and applet security, among other things. You access these preferences by selecting Preferences from the Edit menu. The following list briefly explains the submenu items of interest available under the Preferences menu:

Figure 3.2: Contents of the Preferences/Display form.

  • Display-This option loads a form that contains several entry fields (see Figure 3.2). This form allows the user to change default font sizes, set a home page, and control the display of the HotJava welcome screen.
  • Applet Security-This is the most interesting of the Edit menu options. HotJava actually allows the user to disable (or weaken) the default security precautions to allow applets complete file access on your local machine, as well as the ability to communicate with other computers across the Internet (in addition to the server from which the applet was sent). Unless you have good reason for not doing so, these security settings should be set to the following:

    Network Access = Applet Host
    Class Access = Restricted

  • If, for some reason, you want to configure your HotJava browser to allow applets to read and write files on your local drive, you can do so by modifying the Access Control List in the HotJava properties file. This file is located in the ./.hotjava directory. Although the Access Control List is blank by default, it can be modified by adding the acl_read and acl_write properties, using the following syntax:

    acl_read=[directory_name1 or file_name1]:[directory_nameN or file_nameN]
    acl_write=[directory_name1 or file_name1]:[directory_nameN or file_nameN]

Note
These security settings are completely browser dependent and do not rely in any way on Java or the Java virtual machine. Developers who complain that Java is too restrictive are generally misinformed (or underinformed). In general, it is the Java default implementations that are designed to be restrictive-and for good reason!

Setting View Options

HotJava's View menu contains a set of options that apply specifically to the current page being viewed. The following list briefly explains some of the more important menu items:

  • Monitor-The Monitor option contains the following submenus: Progress, Memory, and Thread. These submenus load HTML pages that can be used to see the current state of various operations. Remember to press the Shift key when selecting any of these options to load a separate HotJava window. Otherwise, these pages replace the current HTML page you are viewing.
  • Monitor Progress-This submenu selection loads a form that shows the progress of the current form load process. Note that a miniature version of the progress bar is located in the right corner of the HotJava browser window. When the progress bar is completely filled, the loading process is finished.
  • Monitor Memory-This selection loads a form that shows a bar graph illustrating the amount of total free memory and the amount of memory that HotJava is currently using. At the bottom of this page is a button that allows you to clean up memory previously allocated by HotJava.
  • Monitor Thread-This submenu selection loads a form showing all active threads in HotJava with their respective priorities and thread groups. It includes options that allow the user to raise and lower thread priorities as well as kill active threads (see Figure 3.3).

Figure 3.3: The HotJava Thread Monitor page.

Content and Protocol Handlers

HotJava is the only Web browser with direct support for dynamic content and protocol handlers. In case you aren't familiar with these concepts, a protocol handler is a piece of code that handles the details of transferring different types of information between a server and client across an Internet connection. A content handler takes information that has been transmitted or received with a protocol handler and determines how that information is processed.

A good example of a protocol is HTTP (HyperText Transfer Protocol), which defines the means in which hypertext documents are transferred between a Web server and client browser. Both the server and client in this case have HTTP protocol handlers that determine how the hypertext information is packaged and transferred. Likewise, an example of a content handler is the component of a Web browser that interprets and displays Web pages based on HTML content sent with the HTTP protocol. All Web browsers must support content and protocol handlers at this level.

HotJava offers a whole new level of abstraction by supporting dynamic content and protocol handlers-meaning that you can add support for new protocol and content types to the HotJava browser without getting a new version of the browser. This modularization of protocol and content types allows the structure of the Web to evolve and change without requiring significant reworking of the browser itself; if a new protocol or content type emerges, you just plug in the handler for it and go!

You learn all about writing your own content and protocol handlers in Chapter 24, "Developing Content and Protocol Handlers."

Netscape Navigator 3.0

If you are like the average Web user, chances are extremely good that you use or have used the Netscape Navigator Web browser. Netscape Navigator is by far the most popular Web browser. In fact, Netscape claims to currently control around 80 percent of the Web browser market with Navigator, although this number is no doubt dropping as Microsoft aggressively pursues Netscape with its Internet Explorer. However, one number Microsoft can't compete with at present is the number of platforms for which Navigator is available. Currently, Navigator is available for a whopping 16 different platforms including Windows 3.1, Windows 95/NT, Apple Macintosh 68K/PowerPC, and Sun Solaris, among others.

Because Navigator-and Internet Explorer, for that matter-has features similar to those discussed earlier in the HotJava Web browser, there's no need to spend a great deal of time discussing each individual feature. Instead, let's turn our attention to its support of Java and related technologies.

Java Support

The most recent version of Netscape Navigator, version 3.0, represents Netscape's most complete support for Java to date. Navigator 3.0 includes full support for both Java applets and JavaScript programs. It even supports the latest version of JavaScript (version 1.1). I guess this doesn't come as too much of a surprise considering that Netscape developed JavaScript! Fig-ure 3.4 shows Netscape Navigator 3.0 in action. You can download Netscape Navigator 3.0 from Netscape's Web site, which is located at http://www.netscape.com.

Figure 3.4: Netscape Navigator 3.0.

Even though core support for Java and JavaScript is extremely important, one of the more exciting features of Navigator is its inclusion of a just-in-time Java compiler in the Windows 95/NT version. If you aren't familiar with just-in-time compilers, they compile Java executables into native machine code on the fly to allow much faster execution speeds. For the details about just-in-time Java compilers, check out Chapter 44, "Just-in-Time Compilers."

Along with all this Java support behind the scenes, Navigator also has a nice feature not found in many other Web browsers: the Java console (see Figure 3.5).

Figure 3.5: Netscape Navigator's Java console.

The Java console allows the user to see exactly which Java applets are being loaded and executed without having to examine the HTML source directly. This feature can come in handy when you are trying to debug Java and HTML forms.

You just learned that Navigator supports JavaScript 1.1, which is a scripting language that allows you to embed scripted programs directly into HTML code. JavaScript was initially introduced by Netscape in an earlier version of Navigator as a feature known as LiveScript. Because Java applets generally do not interact with other elements on HTML pages, JavaScript is useful in providing a means to tie these types of elements together. Although much of the syntax is similar to Java, there are some major differences. Most notably, JavaScript does not allow you to define new types of objects. Additionally, inheritance is not allowed and JavaScript code is not compiled. Instead, it is embedded within the <SCRIPT> and </SCRIPT> tags in an HTML form. Nevertheless, JavaScript is still a very viable alternative for people who want to add a little interactivity to their Web pages without becoming Java experts.

Security

The approach Navigator 3.0 takes in handling applet security is what separates its Java support from the HotJava browser. HotJava allows the user to set security options, but Navigator does not. With Navigator, Java applets are not allowed to read or write to the local file system under any circumstances; applets are restricted to communicating only with the computer from which they came. In addition, unlike users of HotJava, users of Navigator can turn off Java applet support altogether. This feature was provided primarily to pacify users who were concerned over security problems with early versions of Java. Figure 3.6 shows Navigator's Java options.

Figure 3.6: Netscape Navigator's Preferences dialog box.

Microsoft Internet Explorer 3.0

Although late to the game, Microsoft's latest version of the Web browser, Internet Explorer 3.0, is actually full of features-not the least of which is its support for Java and other interactive technologies. Even though Netscape beat Microsoft to the punch with Java support in earlier versions of Netscape Navigator, Microsoft has managed to make up ground fast and even to throw in a few related extras. Internet Explorer 3.0 includes full support for Java applets and JavaScript, including a just-in-time Java compiler. However, Internet Explorer doesn't support the latest version of JavaScript (version 1.1). Figure 3.7 shows Internet Explorer 3.0 in action. You can download Internet Explorer 3.0 from Microsoft's Web site, which is located at http://www.microsoft.com.

Figure 3.7: Microsoft Internet Explorer 3.0.

Perhaps more exciting than Internet Explorer's direct Java support is the inclusion of Microsoft's own ActiveX technology. ActiveX is a powerful new technology built on Microsoft's popular OLE component technology. ActiveX allows Web developers to embed prebuilt software components, called controls, directly in Web pages, much like Java applets are embedded. Also included in ActiveX is a scripting language called VBScript, which is a scaled-down version of the popular Visual Basic programming language. Both ActiveX controls and VBScript programs can be integrated with Java applets, resulting in an interesting mix of new technologies. For more information about the specifics regarding Java and ActiveX, refer to Chapter 38, "Integrating Java and ActiveX."

Java Support

Similar to Netscape Navigator, Internet Explorer supports Java, JavaScript, and a just-in-time Java compiler. Unlike Navigator, Internet Explorer currently supports only version 1.0 of JavaScript (it does not support the newer version 1.1). Also unlike Navigator, Internet Explorer allows you to disable the just-in-time Java compiler. This is done through the Advanced tab of the Options dialog box, shown in Figure 3.8.

Figure 3.8: Microsoft Internet Explorer's Advanced Options dialog box.

In the Advanced Options dialog box, you may also notice that you can enable or disable Java logging, which is a feature that tracks all Java program activity. In a way, this feature is much like the Java console in Navigator, except that it writes information to a file rather than presenting it in a window.

Security

Internet Explorer, like Navigator, takes a hard line when it comes to Java security. As is true in Navigator, Java applets executing in Internet Explorer are not allowed to read or write to the local file system and are restricted to communicating only with the host computer from which they came. Internet Explorer also provides a means to completely disable Java applets. You set this option using the Security tab in the Options dialog box, shown in Figure 3.9.

Figure 3.9: Microsoft Internet Explorer's Security Options dialog box.

In the Security Options dialog box, you may also notice that Internet Explorer allows you to disable ActiveX controls and plug-ins, as well as ActiveX scripts, which includes both JavaScript and VBScript.

Summary

Because Java applets are only as useful as the Web browsers that support them, this chapter introduced you to the latest Java-enabled browsers. Even though Java is still very young, Web browsers have already come a long way in their internal support for Java. And with the competition heating up over which browser will rule the Web, we can only expect better and faster Java support from all these browsers in subsequent versions.

Each browser you learned about in this chapter took a different approach in how it positioned Java next to its other features. HotJava, which is itself entirely written in Java, is the browser most closely wedded to Java. Netscape Navigator, which was the only commercial browser to adopt Java early on, is probably second to HotJava in its support for Java because it includes the latest release of JavaScript. Internet Explorer, although not as firmly linked to the Java camp, includes a very competitive implementation of Java, JavaScript, and a just-in-time Java compiler. Couple this support with ActiveX and VBScript, and Internet Explorer ultimately provides the most options for Web developers.

Now that you have an idea of what's out there in regard to Java browsers, you're probably eager to find out what's available in terms of Java programming tools. Chapter 4 explores the Java Developers Kit, which is JavaSoft's set of tools for Java development.



Ruler image
Contact reference@developer.com with questions or comments.
Copyright 1998 EarthWeb Inc., All rights reserved.
PLEASE READ THE ACCEPTABLE USAGE STATEMENT.
Copyright 1998 Macmillan Computer Publishing. All rights reserved.
Click here for more info

Click here for more info