Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
274
Chapter 12 Including Files and Applets in JSP Documents
12.3 Including Applets for the Java 
Plug In
With JSP, you don't need any special syntax to include ordinary applets: just
use the normal HTML 
APPLET
 tag. However, these applets must use JDK 1.1
or JDK 1.02 since neither Netscape 4.x nor Internet Explorer 5.x support the
Java 2 platform (i.e., JDK 1.2). This lack of support imposes several restric 
tions on applets:
In order to use Swing, you must send the Swing files over the 
network. This process is time consuming and fails in Internet 
Explorer 3 and Netscape 3.x and 4.01 4.05 (which only support 
JDK 1.02), since Swing depends on JDK 1.1. 
You cannot use Java 2D.
You cannot use the Java 2 collections package.
Your code runs more slowly, since most compilers for the Java 2 
platform are significantly improved over their 1.1 predecessors.
Furthermore, early browser releases had a number of inconsistencies in
the way they supported various AWT components, making testing and deliv 
ery of complex user interfaces more burdensome than it ought to have been.
To address this problem, Sun developed a browser plug in for Netscape and
Internet Explorer that lets you use the Java 2 platform for applets in a variety
of browsers. This plug in is available at 
http://java.sun.com/prod 
ucts/plugin/
, and also comes bundled with JDK 1.2.2 and later. Since the
plug in is quite large (several megabytes), it is not reasonable to expect users
on the WWW at large to download and install it just to run your applets. On
the other hand, it is a reasonable alternative for fast corporate intranets, espe 
cially since applets can automatically prompt browsers that lack the plug in to
download it.
Unfortunately, however, the normal 
APPLET
 tag will not work with the
plug in, since browsers are specifically designed to use only their built in vir 
tual machine when they see 
APPLET
. Instead, you have to use a long and
messy 
OBJECT
 tag for Internet Explorer and an equally long 
EMBED
 tag for
Netscape. Furthermore, since you typically don't know which browser type
will be accessing your page, you have to either include both 
OBJECT
 and
EMBED
 (placing the 
EMBED
 within the 
COMMENT
 section of 
OBJECT
) or identify
the browser type at the time of the request and conditionally build the right
tag. This process is straightforward but tedious and time consuming.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved