Preinitialization of Servlet

 A container does not initialize the servlets as soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The servlet specification defines the element, which can be specified in the deployment descriptor to make the servlet container load and initialize the ...

forward and sendRedirect

Whenever there is a request from the client (or browser) to the server, the server container creates two objects 1. request 2. response and pass these objects to the servlet along with other parameters if needed.    S.No.  RequestDispatcher.forward  HttpServletResponse.sendRedirect  1. the request is forwarded to other resource(say B) in the same context, B does some ...

flushing buffer means?

Flushing means the data processed so far can go to the client even if the rest of the page isn’t done yet. It’s useful when you have a lot of data to send like in a download. flush=true : means send to client flush=false : means wait.

Attributes and Parameters in Servlets

   Attributes  Parameters  Types 1. Application/context 2. Request 3. Session  1. Application/context init parameters 2. Request parameters 3. Servlet init parameters  Method to set  setAttribute(String name, Object value)  You CANNOT set Application and Servlet init parameters—they’re set in the DD,  Return type  Object  String  Method to get  getAttribute(String name)  return type of the method is Object   getInitParameter(String name) ...