This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
FYI, For some requests, a chain of ordered servlets can be invoked rather than just one servlet. The input from the browser is sent to the first servlet in the chain and the output from the last servlet in the chain is the response sent back to the browser. Each servlet in the chain has the inputs and outputs piped to the servlet before and after it, respectively. (from Sun's documentation)
getServletContext().getServlet("name"), which is nothing but a method call, is deprecated and always returns null, and it's in the API for backward compatibility.
"Servlet Chaining" is an old term - I think the preferred approach now is to use the "FilterChain" Interface to control passing request and response between servlets. FilterChain was introduced in version 2.3 of the servlet API. Bill
Joined: Feb 10, 2005
Originally posted by William Brogden: "Servlet Chaining" is an old term - I think the preferred approach now is to use the "FilterChain" Interface to control passing request and response between servlets. FilterChain was introduced in version 2.3 of the servlet API. Bill
I think they are similar in the sense that both utilize the forward mechanism. But, there is a difference such that you must declare in web.xml the intercepting filter and map it to the servlet name or url to be filtered. As for the 'Servlet Chaining', if a request is forwarded from one servlet/jsp to another, that is called servlet chaining.
In addition, the filter is used to filter not only request, but also response. If two filters A and B are declared for the same url pattern, the request is first filtered by A and then B. The response can also be filtered by those filters in reverse order, B and A. So the response can be altered by the filters as needed. I hope my understanding is right...
Regards, [ April 03, 2005: Message edited by: Heonkoo Lee ]