Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet chaining

 
tcspillai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me the exact purpose of using servlet chaining
probably with an example???
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet chaining was a way of passing the response from one servlet to another servlet as part of the request (as I understand it). I think this was never part of the official API, but something added by some vendors.
The latest API 2.3 has "Filters" which provide a formal method of specifying a filter that looks at and may modify a request before sending it on to a servlet, also the same thing on the output end. As it happens, I am just now reading the comments on Filters in the Tomcat 4.0 distribution:
"You can now register Filters in the web.xml file that are the application level analogue to Valves in the Catalina core. Filters have the following general features:
- Filters can be mapped to either URL patterns or particular servlets
- Filters can pre-process and post-process requests and responses
- Filters can wrap the request and/or response objects that are passed on
(so you can do content type transformations, for example)
- Filters can respond to a request and return, instead of passing the request on (for example, you can do authentication challenges at the app level)
Related to this, servlets can now do the same sort of wrapping when they pass arguments to a RequestDispatcher. Previously, you were required to pass the original request and response objects received from the container.
"
Some uses that occur to me:
Encryption/decryption
Transformation of XML output of a servlet by a filter using a selected XSL transform.
Bill

------------------
author of:
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"tcspillai",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic