Saturday, July 9, 2011

What is Java Servlet

A servlet is a Java technology-based Web component answer to CGI programming, managed by a container that generates dynamic content. CGI was widely used for generating dynamic content before Servlets arrived. They were programs written mostly in C,C++ that run on a web server and used to build web pages.
Like other Java technology-based components, servlets are platform independent Java classes that are
compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology enabled Web server. Containers, sometimes called servlet engines, are Web server extensions that provide servlet functionality. Servlets interact with Web clients via a request / response paradigm implemented by the servlet container.

As you can see in the figure below, a client sends a request to web server, server forwards that request to a servlet, servlet generates dynamic content, mostly in the form of HTML pages, and returns it back to the server, which sends it back to the client. Hence we can say that servlet is extending the functionality of the web server (The job of the earlier servers was to respond only to request, by may be sending the required html file back to the client, and generally no processing was performed on the server)

 Related Topics:

What is Java Servlet Life Cycle and how to explain it
What is Servlet Class Hierarchy
What are Java Servlet different HTTP Request Handling Methods

2 comments:

Please enter relevant question and information.