Hi Friends
Whats the that the GenericServlet and HttpServlet class implement Serializable interface? What happen if we not do show.
Thanks........
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jan 9, 2012, 12:26 PM
In order to support HTTP session states, all servlet session data must be serializable.Moreover, servlets need to communicate over the network to Java objects(e.g. in Applet-Servlet communication),in such scenarios it becomes necessary to enable serialization of objects' states through implementation of Serializable interface.This is the way GenericServlet and HttpServlet classes have been designed by their designers to make them capable of serialization.
HttpServlet belongs to javax.servlet.http package.
HttpServlet extends GenericServlet . HttpServlet Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these:
doGet, if the servlet supports HTTP GET requests
doPost, for HTTP POST requests
doPut, for HTTP PUT requests
doDelete, for HTTP DELETE requests
GenericServlet defines a generic, protocol-independent servlet. GenericServlet belongs to javax.servlet package . To write a generic servlet, you need only override the abstract service method.GenericServlet implements the Servlet and ServletConfig interfaces. GenericServlet may be directly extended by a servlet, although it?s more common to extend a protocol-specific subclass such as HttpServlet.
GenericServlet makes writing servlets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface.
Thanks
Vikas MishraPosted Jan 9, 2012, 5:10 PM
VulpesPosted Jan 9, 2012, 12:09 PM
http://docs.oracle.com/javaee/1.3/api/javax/servlet/GenericServlet.html
http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/HttpServlet.html