Servlets

Servlet Hierarchy

A servlet is an object that extends either the javax.servlet.GenericServlet class or the javax.servlet.http.HttpServlet class.
The javax.servlet.GenericServlet class defines methods for building generic, protocol-independent servlets.
The javax.servlet.http.HttpServlet class extends this class to provide HTTP-specific methods.

Maven dependency - Adding the javadoc to the servlet package

javax.servlet.http

http://stackoverflow.com/questions/4379375/how-to-get-eclipsemaven-to-find-and-use-servlet-api-source-code-or-javadoc

(Web) Application context

ServletContext context = getServletContext();

There is one context per "web application" per Java Virtual Machine.

A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.

In distributed environment, the context cannot be used as a location to share global information.Use an external resource like a database instead.

The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized

RequestDispatcher

Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server.

The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.

This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource.