The java.servlet.Servlet interface defines 3 methos known as life-cycle method.
1. public void init(ServletConfig config) throws ServletException: servlet is constructe, then initialized with the init() method.
2. public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException: any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
3. public void destroy(): Servlet is removed from service, destroyed with the destroy() method, then garbage collected and finalized.
What is the difference between doGet() and doPost()?
doGet() mthod is limited with 2k of data to be sent, and doPost() mehtod doesn’t have this limitation. A request string for doGet() looks like the following: http://www.google.com/svt1?p1=v1&p2=v2&…&pN=vN. doPost() method call doesntneed a long texttail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and its impossible to guess the data transmitted to a servlet only looking at the request string.
HttpServlet and GenericServlet: GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and addes support for doGet(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods. Both these classes are abstract.
ServletContext and ServletConfig: ServletContext defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. The ServletContext object is contained within the ServletConfig object, which the web server provides the servlet when the servlet is initialized.
ServletConfig: the object created after a servlet is instantiated and its default constructor is read. It is created to pass initialization infomation to the servlet.

