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

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

pooja said...
6 August 2015 at 10:38

b


Unknown 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


Anonymous 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


ciitnoida said...
23 April 2018 at 17:11

CIIT Noida provides Best MCA Courses in Noida based on the current

IT industry standards that help students to get high paying jobs in Top MNCs. CIIT provides Best MCA Training in Noida, Greater Noida, and Ghaziabad.

CIIT is one of the trusted MCA training institutes in Noida providing practical knowledge and 100% job assistance with basic as well as advanced

level MCA subjects. CIITN is the best MCA college in Noida, greater noida, ghaziabad, delhi, gurgaon regoin.

At CIIT MCA classes in Noida is conducted by subject experts corporate professionals with 9+ years of experience in managing real-time and live

projects. Sofracle Nano Specialized MCA classes Noida is the perfect blend of academic learning and practical sessions to provide maximum exposure to

students that transform an average student into a corporate professional whom companies prefer to hire.

Best MCA College in Noida


Sathyatech said...
11 December 2018 at 16:48

Thank you for sharing article on servlet Interface...

Software Training courses in hyderabad | Java Training course in hyderabad


Digital Brolly said...
13 December 2018 at 20:10

Informative blog...

Wordpress website development workshop | Digital marketing course with internship


Post a Comment

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar