Posts

Showing posts with the label Servlets

In Detail : The Request Object In Servlets

     The request object encapsulates all information from the client request. The information from the clients is transmitted to the server in the form of HTTP headers and the message body of the request through the HTTP protocol. What are the HTTP Protocol Parameters ?       Request parameters for the servlet are nothing but strings sent by the client to a servlet container as part of its request. When the request is an HttpServletRequest object, and conditions set out are met, the container populates the parameters from the URI query string and POST-ed data. The parameters are stored as a set of name-value pairs. Multiple parameter values can exist for any given parameter name. The following methods of the ServletRequest interface are available to access parameters. getParameter() getParameterNames() getParameterValues() getParameterMap() The getParameterValues method returns an array of String objects containing all the parameter v...

Bored Of Simple Servlet Life Cycle, Here Is, In Detail , The Servlet Life Cycle

       A servlet goes through the well defined life cycle that defines how the sevlet is loaded , instantiated, and is initialized, handles requests from clients, and how the servlet is taken out of the service. This whole life cycle is expressed in the API by the init, service, and destroy methods of the javax.servlet.Servlet interface that all the servlets must implement directly or indirectly through the GenericServlet or HttpServlet abstract class. Loading and Instantiation :      Who is responsible for loading and instantiating servlets ? Well , the servlet container will take care about these things. The loading and instantiation can occur when the container is started, or delayed until the container determines the servlet is needed to service a request. When the servlet engine is started, needed servlet classes must be located by servlet container. The servlet container loads the servlet classes using the normal Java class loading facili...

How to Implement Servlets

The Servlet Interface :       The Servlet interface is the central abstraction of the Java Servlet API. All servlets implement this interface either directly, or more commonly, by extending a class that implements the interface. The two classes in the Java Servlet API that implement the Servlet interface are GenericServlet and HttpServlet. For most purposes, Developers will extend HttpServlet to implement their servlets. Request Handling Methods :       The basic Servlet interface defines a service method for handling client requests. This method is called for each request that the servlet container routes to an instance of a servlet. The Web container handles concurrent requests to the same servlet by concurrent execution of the service method on different threads. HTTP Specific Request Handling Methods :       The client can make the request to the web server using HTTP protocol. The HttpServlet abstract subclass adds addition...

Introduction To Servlets

What is a Servlet ?             A servlet is a java technology based Web component, managed by a container, that generates dynamic content. Servlets run on the servers, hence is the name Servlets. 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. What is a Servlet Container ?         The servlet container is a part of a Web server or application server that provides the network services over which requests and responses are sent, decodes MIME - based requests, and formats MIME - based responses. A servlet container also contains and manage...