Servlet logo
Servlet Tutorial

Overview  
HTTP/CGI  
Servlets  
JSP  
Resources  

Zameer's Education


 

Introduction | Servlets & HTTP | Life-Cycle | Sessions | Summary | Examples

A servlet is a server extension. It should be a small, self-contained, portion of code that is executed at the web server in response to an HTTP request. Servlets are written in Java and once inside a servlet, a developer has access to all the resources available on the Java 2 Platform. Servlets are gateways from the web tier into the enterprise using key middleware solutions such as RMI, CORBA, JMS, MQ, JNDI and so on.

A servlet engine provides the runtime environment in which a servlet executes. The servlet engine manages the life-cycle of servlets from when they are first created through to their imminient destruction. The servlet engine exposes an API based on the version of the servlet specification that it implements. It is this Servlet API that developers write their servlets against. The result, servlet portability between servlet engines that adhere to the specification.

But how portable are servlet engines across properitary web servers? Well, does it matter to you the developer? Not really. So long as the servlet engine exposes the required servlet API, your good to go. This is a question for the vendors that are the implementors of servlet engines. Some have implemented them natively for the major web servers such as IIS/ISAPI and Netcape/NSAPI whilst others have written them in pure Java (eg. Jigsaw, Tomcat). But at the end of the day, you pick a servlet engine that satisfies your project requirements.



Relationship between web server, servlet Engine and servlets

Servlet engines come in two flavours: standalone and add-on. A standalone servlet engine is a fully functioning web server with support for servlets, for example, WebSphere, Java Web Server, IPlanet and W3's Jigsaw. An add-on servlet engine is a plug-in that can be added to a web server to give it the servlet support it was probably never designed to have. Examples of add-on servlet engines are ServletExec and Tomcat, the former being very easy to configure so that even IIS can comfortably support Java Servlets!

Servlets are a powerful mechanism for a Java programmer to gain access an object-oriented abstraction of HTTP. Servlets are portable across web servers, simple to design and implement, have tight integration with the web server, service requests in an efficient manner and run within the secure and reliable scope of a Java Virtual Machine (JVM). In the next section will take a closer look at the Servlet API and see what interfaces and classes it arms Java web developers with.

 
  (c) Zameer's Online Education 2006