You are here:   HomeJava Servlet
by Dinesh Thakur Category: Servlet Chaining

Taking a request from a browser window and processing it by using multiple servlets as a chain is called Servlet Chaining. In servlet chaining, communication occurs between servlet chains and servlet programs to process the request given by a client.



 
by Dinesh Thakur Category: Servlet Chaining

This method sends a temporary redirect response to the client using the mentioned redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading ‘/’ the container interprets it as relative to the current request URL. If the location is relative with a leading ‘/’ the container interprets it as relative to the servlet container root.



 
by Dinesh Thakur Category: Servlet Chaining

This method forwards a request from a servlet to another resource (servlet, JSP file or HTML file) on the server. It enables one servlet to do prelude processing of a request and another resource to create the response.



 
by Dinesh Thakur Category: Servlet Chaining

While building a complex web application there might be a need to distribute the request to multiple servlets. This is where request dispatching comes into use. Due to this requirement Servlet container supports request dispatching within the same context.



 
by Dinesh Thakur Category: Servlet Chaining

In the diagram Below, Srvl program forwards the request to Srv2 only when the generated square value is less than 100,otherwise, the Srvl directly sends response to browser window displaying that square value.

 
by Dinesh Thakur Category: Servlet Chaining

GETREQUESTDISPATCHER ()

lnvokable on both request, servletContext object. Expects URL pattern of destination JSP or HTML programs as argument value. Generated RequestDispatcher object can point the destination servlet JSP program and HTML program.



 
by Dinesh Thakur Category: Servlet Chaining

• In any mode of servlet chaining, all servlet programs/web resource programs use the same request and response objects. If srvI, srv2, srv3 and srv4 servlet programs are in forwarding request mode of servlet chaining, the html output of srv1, srv and srv3 is discarded and only the output of srv4 servlet program goes to the browser window.



 
by Dinesh Thakur Category: Servlet Chaining

The request object based RequestDispatcher object expects that the source servlet Program, destination web resource program and the destination web resource program be in the same web application.



 

Page 24 of 24

What's New and Popular





Search Content







Advance Courses



Basic Courses



Advertise with Us