To Applet Or Not To Applet

Applets may not be a “perfect” delivery vehicle for intranets (or extranets for that matter) as we might be made to believe.
Advantages:
1. They provide richer “GUI”
2. They take the load off the server (because the client machine does processing).
3. For special circumstances e.g. If non-text data is to be processed at the client side etc.
Disadvantages:
1. It is slower (initial load time) for the user.
2. It requires installation of the java plug-in at the client browser.
3. The capabilities of an untrusted applet are limited (because of security). No printing, copy-paste, accessing client machine files etc.
The disadvantages get mitigated in an intranet environment because
a. The users are internal (or rather captive); they can be made to tolerate a slower application.
b. The application deployer can control the client environment i.e. instruct the user to install such and such plug-in etc
Having said this, the usual procedure is – don’t go for applets (whether in an intranet or extranet) unless there is a compelling reason to do so. The most likely instance is, if you have UI requirements that cannot be satisfied by plain old HTML.
Then again, it is not an either-or decision. It is usually the case to have a mix and match of JSP and Applet screens in the same application.
Architectures for Applet based Applications
There is no difference in the network environment requirements (intranet /extranet/LAN etc.) as far as Applets are concerned. It would operate in the same environment as a JSP/ J2EE Application.
There are two possible architectures for applet-based applications.
1. Client-Server
This is very rarely (if at all) used. In this architecture the applet code directly accesses the back-end database. This has none of the advantages of J2EE – no database transaction integrity, no scalability, etc. Also, this would require extra database related set-up on the client machine.
Also, this has an overriding disadvantage that it will ONLY work in an intranet/ LAN environment. In a extranet application, firewall administrators allow remote machines to connect to only port 80 for HTTP, port 21 for FTP etc.
It’s unlikely that applets running on remote machines on an extranet will be permitted to access the database ports (whichever port number that is, depends on what database is being used).
2. Applets in a J2EE setup
This is the more common way of using applets. Applets replace the JSPs used in the application. Everything else in the J2EE setup remains the same- servlets, EJBs etc.
This is ideal for using a mix and match of JSPs+Applets in the application.
The Applet communicates with a servlet on the application server and passes serialized java objects back and forth using a technique called HTTP tunneling. It uses the regular HTTP port for communication and hence is not at risk for firewall port blocking.

Some FAQs:

Q. What do you mean by an applet running on a remote machine?
A.An applet runs within a browser installed on the client machine. Its nothing but a piece of java code that executes within the scope of a client machine browser. To “run” it you need the java plug-in. (runtime environment) installed on the client machine.
It is more than just dumb display of text (which is what HTML is).
Hence it is more powerful than HTML.

Q. What is the security manager? What is a trusted applet?
A. If you need the applet to do some usually “prohibited” things (like printing, copy/paste, file access etc.) then you need to use a trusted applet. It involves a security certificate to be installed and some other stuff.
The reason for this “prohibited” restriction is that, while browsing the World Wide Web you don’t want any tom, dick and harry’s applet to gain access to your personal machine and create havoc.

NB: In the above discussion for all purposes intranet is synonymous with LAN.

About cuppajavamattiz
Matty Jacob - Avid technical blogger with interests in J2EE, Web Application Servers, Web frameworks, Open source libraries, Relational Databases, Web Services, Source control repositories, ETL, IDE Tools and related technologies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: