Introduction To Java Servlets.

Computers & Internet Article Directory, Get Free Reprint Articles and Computers & Internet Content for your site with
article directory
54866 *recent articles in 509 categories Last article added 11/15/07
 
Article Categories
 
Reviews
 
Site Menu
 
Site Search


 
ArticlePros.com » Computers & Internet » Programming » Introduction To Java Servlets.

  • Date: 2007-08-06
  • Author: sudhir nimavat
  • All articles by this author
  • Visit author's website
  • Introduction To Java Servlets.


    Related Programming Articles

         A servlet is a Java technology based web component, managed by a container, that
    generates dynamic content.

    A servlet can be considered as a tiny Java program which processes user request and generates dynamic content.

    There are many other alternatives like php, asp .net or CGI, for developing dynamic web sites. benefit of using servlets
    over other technologies is servlets are developed in Java, so it comes with all benefits of Java language and it
    is platform independent.

    Following are the some advantages of using servlets.

    (1) They are generally much faster than CGI scripts.
    (2) They use a standard API that is supported by many web servers.
    (3) They have all the advantages of the Java programming language, including
    ease of development and platform independence.
    (4) They can access the large set of APIs available for the Java platform.

    What is a Servlet Container?
    Servlet container is a runtime environment, which implements servlet API and manages life cycle of servlet components.
    Container is responsible for instantiating, invoking, and destroying servlet components.
    One example of container is Apache Tomcat which is an opensource container.

    Servlet Life Cycle :
    A servlet is managed through a well defined life cycle which defines how it is loaded,
    instantiated and initialized, handles requests from clients, and how it is taken out of
    service.

    The servlet life cycle is consist of following phases.

    (1) Instantiation
    During this phase container creates a new instance of servlet. this is the first phase of servlet life cycle.

    (2) Initialization
    After the servlet object is instantiated, the container initializes the servlet before
    it can handle requests from clients. during this phase container calls the init() method of servlet.
    This is the second phase of servlet life cycle.

    (3) Request Handling
    Actual request processing and response generation occurs during this phase.
    Container calls service() method of servlet component and passes ServletRequest and ServletResponse objects as parameter.

    (4) Destroy
    This is the last phase of servlet life cycle. during this phase container calls destroy() method of servlet component.
    After this phase servlet is removed from service. this happens when server is shutting down, or server wants to free some memory.

    All of this life cycle methods are defined in Servlet interface.

    following methods are defined in Servlet interface

    public void init(ServletConfig config)
    public ServletConfig getServletConfig()
    public void service(ServletRequest req,ServletResponse res)
    public void destroy()

    Current version of servlet specification is 2.5

    More articles from this pro: http://www.ArticlePros.com/author.php?sudhir nimavat


    More on Computers & Internet and Programming can be found here.
     

    Get this article to go

    RSS | JScript | Email | HTML

     

    About the author

    This article can be reprinted with link <a href="http://www.jayog.com">Java articles and tutorials </a>
    sudhir

    http://www.jyog.com

     
    Email options
       

    ** Check all that apply **

     

    This article has been accessed 153 times since 2007-08-06.


    Home  •  Search  •  Add Your Own Article  •  RSS feeds  •  JavaScript Feeds  •   •  Set as Homepage  •  Add to Favourites
    Disclaimer: The information presented and opinions expressed herein are those of the authors
    and do not necessarily represent the views of ArticlePros.com and/or its partners.
    Copyright ArticlePros.com © 2005. All Rights Reserved