Newsletter

What is servlet? An Introduction to Java Servlets

Servlets » on Jan 4, 2013 { 11 Comments } By Sivateja

The basic aim of servlet is to develop web applications.  Before servlets came into picture there was a specification called CGI.  Servlets specification developed by SUN and released to the industry.   Lot of server vendors came forward for implementing these specifications of servlets.  Servlets are nothing but set of rules given by SUN in the form of Interfaces.  The server vendors have developed their own classes by implementing the interfaces developed by SUN.

The collection of classes developed by server vendors and Interfaces developed by SUN are known as Servlet-API.

What is servlet

A servlet is a server side platform independent, dynamic and multithread java program, which runs in the context of server for extending the functionality of server.  When multiple users make a request to the same servlet then all requests will be processed by the container by creating multiple threads for the same servlet. In order to deal with these servlet programming, we must import

javax.servlet.*;
javax.servlet.http.*;

into our java program.

  • javax.servlet.Servlet is one of pre-defined top most interface, which is containing life cycle methods[init(), service(), destroy() i will describe about these methods later] for servlet.
  • javax.servlet.GenericServlet is one of the predefined abstract class which is implementing javax.servlet.Servlet interface,  this GenericServlet class is used for developing protocol independent applications [ But in real time we will use protocol dependent applications only, so GenericServlet won’t be appeared in real time ]
  • Javax.servlet.http.HttpServlet is sub class of GenericServlet used for developing protocol dependent application  [ HTTP protocol ]

Consider Myserlet.java is our own class always recommended to extends HttpServlet servlet, as our current internet world is supporting HTTP protocol right 🙂  In real time, we will use HttpServlet only not GenericServlet remember.

You Might Also Like

  ::. About the Author .::

Java4s_Author
- Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

11 Responses to “What is servlet? An Introduction to Java Servlets”
  1. suresh says:

    pls can u explain how can read excel sheets in servlets?

  2. Can u let me know how to create servelt object by using class.forName()

  3. Saket says:

    Awesum tutorial!! m loving it!!!

  4. subbu says:

    what is the purpose of init()method already we have life cycle method init(-)?

  5. what is listener class in servlet?

  6. devon says:

    wow!! bst tutorial…

  7. Sreenivas says:

    Friendly Explanation .

  8. nandini says:

    Friendly explanation

  9. raju says:

    GenericServlet Class not concrete class it is a abstract class.this class service () method is abstract

  10. sainath Eklare says:

    Goood For Teaching The Java Knowledge

  11. Thanks for sharing such an informative blog. This blog gives information about what is servlet with examples. Great blog. This blog is really helpful to many people.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.