Home Tutorial Servlet Java : What is servlet?

 
 

Share on Google+Share on Google+
Java : What is servlet?
Posted on: November 21, 2012 at 12:00 AM
Advertisement
This section define the concept of java servlet.

Java : What is servlet?

This section define the concept of java servlet.

Servlet :

Servlets are small java programs run on web server. You can say these are server side programming. It works between client request and the server. Request is generated by the web browser or HTTP client and database for server, which is handled by the servlet.

We use javax.servlet and javax.servlet.http packages for writing servlets. These packages provide interfaces and classes for our servlets. When you writing any servlets, its required to implements the Servlet interface which defines the lifecycle methods. For generic service you can use or extend the GenericServlet class. For handling HTTP-specific service, HttpServlet class gives you methods, such as doGet and doPost.

Using servlets web developers can create fast and efficient server side applications and can run it on any servlet enabled web server. Servlet runs entirely inside the Java Virtual Machine. Since the servlet runs on server side so it does not depend on browser compatibility.

CGI vs Servlet - Advantages of Servlets over the CGI-

  • Platform Independence- Written in java so its platform independent.
  • Performance- its performance is better than the CGI
  • Extensibility- It is well defined and can be extended from existing classes.
  • Safe and Secure - Java security manager provides protection to the resources on a server by applying set of restrictions.

Servlet Architecture view - Following picture is overview of Servlets. It is showing the hierarchy of inheriting the Servlet interface. The main abstraction of Servlet API is the Servlet interface. Servlets implements this interface directly or by extending class that implements it.

Advertisement

Related Tags for Java : What is servlet?:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 21, 2012

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com