Back to Top

Wednesday, 29 February 2012

J2EE: SERVLET: What is Servlet Interface?


Interface javax.servlet.Servlet is that interface which defines the ServletLife Cycle methods. So, all servlets must implement this interface, either directly or by extending a class which implements this interface. Instead of directly implementing the Servlet Interface, a servlet can also extend Class GenericServlet (which implements Servlet Interface), or can extend HttpServlet Class (which extends the GenericServlet class).



Methods of Interface Servlet:
  • init(ServletConfig config) : Called by the Web Container to initialize a servlet. Here, config  is a ServletConfig object containing the servlet's configuration and initialization parameters      
  • service(ServletRequest req, ServletResponse res) : Called by the Web Container to allow a servlet to respond to a request. Here, req is the ServletRequest object that contains the client's request and res is the ServletResponse object that contains the servlet's response.

  • destroy() : Called by the Web Container to clean up a servlet’s service.

  • getServletConfig() : Return a ServletConfig object, which contain the initialization parameter and startup configuration of a servlet.

  • getServletInfo() : Returns a string containing the details of a servlet, like author, version and copyright.
Anijit Sarkar

7 Responses to “ J2EE: SERVLET: What is Servlet Interface? ”

Anonymous said...
26 December 2012 at 10:36

very nice


Pooja Tiwari said...
6 August 2015 at 10:38

b


Naviya Nair said...
24 October 2016 at 15:00

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai


Karthika Shree said...
19 May 2017 at 10:57

It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
Java Training in Chennai


Vamshi Krishna said...
30 May 2017 at 17:52


very useful info, and please keep updating........


preethi s said...
6 June 2017 at 16:50

It is really a great work and the way in which u r sharing the knowledge is excellent.
Thanks for helping me to understand basic concepts.thank u so much for this nice blog .
java training in chennai |
java training institutes in chennai


kim john said...
13 October 2017 at 11:13

Really you have done a great job. Your post helped me a lot in the preparation of my technical interview.
Java Training in Chennai
Java Course in Chennai
Best Java Training in Chennai


Post a Comment

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs