A GenericServlet has a service() method to handle requests. HttpServlet extends GenericServlet added new methods
doGet() doPost() doHead() doPut() doOptions() doDelete() doTrace() methods
Both these classes are abstract.
Servlets executes on Servers. Applets executes on browser. Unlike applets, however, servlets have no graphical user interface.
The getRequestDispatcher(String path) method of ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a “/” it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of ServletContext interface cannot accepts relative paths. All path must sart with a “/” and are interpreted as relative to curent context root. If the resource is not available, or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition.
Using include method of a RequestDispatcher object.
Included WebComponent (Servlet / Jsp) cannot set headers or call any method (for example, setCookie) that affects the headers of the response.
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(”/banner”); if (dispatcher != null) dispatcher.include(request, response); }
A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The Servlet specification defines the <load-on-startup> element, which can be specified in the deployment descriptor to make the Servlet container load and initialize the Servlet as soon as it starts up. The process of loading a servlet before any request comes in is called preloading or preinitializing a Servlet.