Monday, June 25, 2012

Need of a Servlet.

Web Programming for static Information

  1. Client sends a request for a static file. 
  2. Server searches whether the requested static file is available or not 
  3. If the requested static file is available then web server provides that file as the response otherwise, it provides 404 status code saying requested resource is not available.
Note:   To serve static file no process is required at server side, hence webserver always love to serve static information as response.




Web Programming for dynamic Information


  1. Client sends a request. 
  2. If the request is for static files then,server searches whether the requested static file is available or not.
  3. If the requested static file is available then web server provides that file as the response otherwise, it provides 404 status code saying requested resource is not available. 
  4. If the request is for dynamic information then web server forwards that request to some helper application. 
  5. Helper application analyses the request and process the request and generates the required dynamic information. 
  6. Helper application forwards that dynamic response to the web server and web server intern forwards that response to the client.

The following are the various helper applications available in the market.
                Servlet, jsp, asp, asp.net, cold fusion, php, SSJS, CGI
For the generation of dynamic data we need the helper application as shown in the above diagram.  Our Servlet acts as a helper application to generate the dynamic responses to the clients request.
                To run this helper application it needs some environment.  That environment will be provided by the web container. Web container is responsible for maintaining these helper applications.
Now we can say a servlet is:
Servlet is a server side web component managed by the web container that generates the dynamic responses.

7 comments:

  1. Replies
    1. SSJS stands for server side java script. It is also like servlets which is used to generate the dynamic responses.

      Delete
  2. Replies
    1. Filter is a component like Servlet which will intercept the http request and do some operations on the request before hitting the backend. If we want to do any preprocessing of a request and post processing of a response we will use Filters(Servlet filters).
      For example: if a student can upload a resume in different formats like .trf, txt and doc formats. If the database or our application accepts only specific format lets say .docs format, in this case filter can be used to intercept that request and convert the uploaded file into the accepted format then it will send to the actual logic where that file will be saved.
      In some cases data can be in copressed format from the server in that case we will decompress it and we will show it to the client. This is the example for post processing of a response.

      Delete