Servlet : Java Glossary
home S words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
Servlet
an application designed to run on a server in the womb of a permanently resident CGI mother program written in Java that provides services for it, much the way an Applet runs in the womb of a Web browser.

Servlet Advantages

Servlets have the following advantages over CGI.

Servlet Extensions

It gets tedious writing Servlets that embed reams of HTML inside Java strings, since your outputs are complete HTML pages. So people have created scores of rinky dink ways of embedding Java code in HTML that gets compiled into the equivalent Java Servlet code dynamically. I find them all disgustingly amateurish. You might have a look at some of the choices of framework.

There are various ways of writing server code that build on top of the basic Servlet classes. JSP and Freemarker let you embed bits of Java code, and other scripting inside your HTML pages. These are parsed and converted to Java Servlet programs that dynamically generate HTML with variable fields. These are automatically recompiled as needed.

With JSP all you have to do is drop the *.jsp files in a magic directory and away you go. With Servlets you must put the *.class files or *.war files in a magic directory, and register the servlets in a web.xml file that maps application name to servlet class among other things.

Writing Servlets in XML

In the following web.app example, the user types http://localhost:8080/hello. That is mapped to a servlet named hello-world. That servlet is implemented by the Java Servlet test.HelloWorld.class.
<web-app>
<servlet-mapping url-pattern='/hello' servlet-name='hello-world'/>
<servlet servlet-name='hello-world' servlet-class='test.HelloWorld'/>
<init-param greeting='Hello, world'/>
</web-app>

Under the Hood

The big puzzle to the novice is where are the jars for the Servlet classes?
// imports used in Servlets
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
Sun does not provide the jars. You get them from your servlet womb vendor — his particular implementation of the interfaces. If you use Caucho Resin, it will automatically use its version of the classes and automatically recompile your java source as-needed. You have to read the womb docs. Often they make you copy the entire set of system jars to your own directory for use.

Sun does provide some

so you can compile without having a womb, but that is not very useful. You can’t execute the code. To run, you need a servlet womb.

javax.servlet.Filter is an interface to allow a transaction to be processed in an assembly line. Each Filter does some of the work and passes on the input or output to the next filter in the chain, and decides on who is next.

Getting Started

Getting your first HelloServletWorld working can be quite a challenge.

Debugging Tips

Learning More

javax.servlet.http.HttpServlet docs : available:

javax.servlet.http package docs : available:

javax.servlet package docs : available:

See this tutorial and sample code collection.

See this tutorial on Servlet Essentials.

book_cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN13:978-0-13-089340-6
ISBN10:0-13-089340-4clickcounter
publisher:Prentice Hall
published:2000-05-26
by:Marty Hall
Complete text of the book available on line in pdf format.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

book_cover recommend book⇒Java Servlet Programming
 paperback
ISBN13:978-0-596-00040-0
ISBN10:0-596-00040-5clickcounter
publisher:O’Reilly recommended
published:2001-01-15
by:Jason Hunter, William Crawford
highly reccommended.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. download O’Reilly Safari American flag
UK flag amazon.co.uk.   

book_cover recommend book⇒Web Development with JavaServer Pages
 paperback
ISBN13:978-1-930110-12-0
ISBN10:1-930110-12-Xclickcounter
publisher:Manning Publications
published:2001-09-15
by:Duane K. Fields, Mark A. Kolb, Shawn Bayern
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

book_cover recommend book⇒Inside Servlets: Server-Side Programming for the Java(TM) Platform (2nd Edition)
 paperback
ISBN13:978-0-201-70906-3
ISBN10:0-201-70906-6clickcounter
publisher:Addison-Wesley
published:2001-05-14
by:Dustin R. Callaway, Danny Coward
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

book_cover recommend book⇒Developing Enterprise Java Applications with J2EE and UML
 paperback
ISBN13:978-0-201-73829-2
ISBN10:0-201-73829-5clickcounter
publisher:Addison-Wesley
published:2001-10-27
by:Khawar Zaman Ahmed, Cary E. Umrysh
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] Visit care2.org
You are visitor number 19,497.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/servlet.html J:\mindprod\jgloss\servlet.html