Skip to main content

Servlets Vs Applets

There are some things to note to note about Servlets as opposed to Applets.

Firstly, the servlet and its environment is completely under the control of those deploying it. That is, you have control of which JVM is used and that this is independent of the browser used by the user. This is important as it removes concerns associated with the so-called “browser” wars.
Secondly, a servlet is not constrained by the applet sandbox. This means that a servlet can reside behind a firewall and can communicate with any and all systems that it needs to. For example, JavaIDL can be used to connected to a CORBA compliant Object Request Broker (ORB) or sockets to connect to legacy systems (for example implemented in C).
Thirdly, the client Web browser does not communicate directly with the servlet. Rather the browser communicates with the Web server, which in turn communicates with the servlet. Thus if the web server is secure behind a firewall, then the servlet is also secure.
Fourthly a single Servlet can process multiple user requests. That is one instance (by default) of a Servlet is loaded into the web server and this instance services all user requests. This does not mean that each request is queued. Rather it means that each request is handled by a separate thread (of execution) that uses the same servlet instance.
Fifthly, as each Servlet is shared amongst multiple users, care must be taken with user specific data. For example, this means that sensitive user information should not be stored in an instance variable as the instance is shared amongst many users. This can be overcome by using a HttpSession object that can be obtained from the initial request. Each session object is linked to a single user.

Comments

Richard said…
Hi Raj,

I'd like to disagree with this statement:

>Firstly, the servlet and its environment is completely under the control of those deploying it.

Traditionally, servlets are accessed by a web browser. Servlets usually output HTML. How this HTML is interpreted is up to the browser that the user is using, which may not be under the control of the deployer of the servlet. There are countless examples of something working in Internet Explorer and not working in Netscape, or vice versa. With DHTML, CSS, javascript, etc. there are countless incompatibilities that a servlet deployer has to take into account when writing a servlet.

Rich
Rajneesh Garg said…
Hi Rich,

I agree with your point of view. The statement made in the Post was a generalized one and was made in the context of distinguishing Servlet from an Applet.

Popular posts from this blog

Installing Bugzilla on Windows

Bugzilla is the Bugs/Issues Tracking Tool from The Mozilla Organization. Version 2.18 is the latest stable release. There are couple of resources which guide a User installing Bugzilla on a Unix/linux machine. However, this entry describes a way to install Bugzilla on a Windows machine (W2K to be precise). This document guides you step by step through the installation process. First, get Administrative access to the machine on which you want to install Bugzilla. It should be a simple step. Usually, Users are given Administrative rights on Windows machine. However, if you dont have, contact your Administrator. Get Bugzilla Then download the Bugzilla from http://bugzilla.org/download.html . There are two ways of gettng it - through CVS or direct downloading the tar file. Remember there are no Zip files. However, any zip utility should be able to untar the Bugzilla. I download the tar file and untarred it using WinZip. I placed the untarred 'bugzilla' directory in my c: drive. So...

JSP Performance Tips

Here are a few tips to improve JSP performance that I have been using. If you have your own listing of the tips, plz share. Disable JSP auto reloading feature. Use thread pool for your JSP engine and define the size of thread pool as per application requirement. Use jspInit() method to cache static data Initialize the 'out' object (implicit object) with proper size in the page directive. Set the content length Give 'false' value to the session in the page directive to avoid session object creation. Flush the data partly Use StringBuffer rather than using + operator when you concatenate multiple strings Use include directive instead of include action when you want to include the child page content in the translation phase. Avoid giving unnecessary scope in the 'useBean' action. Use print() method rather than println() method Use ServletOutputStream instead of JSPWriter to send binary data Minimize code in the synchronized block Do not use custom tags if you do no...

How old are the daughters?

Two MIT math graduates bump into each other at Fairway on the upper west side. They hadn't seen each other in over 20 years. The first grad says to the second: "how have you been?" Second: "Great! I got married and I have three daughters now" First: "Really? how old are they?" Second: "Well, the product of their ages is 72, and the sum of their ages is the same as the number on that building over there.." First: "Right, ok.. oh wait.. hmmmm.., I still don't know" second: "Oh sorry, the oldest one just started to play the piano" First: "Wonderful! my oldest is the same age!" Problem: How old are the daughters?