Cooperating Tags in JSP
by, 07-07-2012 at 06:55 PM (1020 Views)
Java Server Pages provides support for two types of object sharing. This object sharing is achieved using cooperating tags.
• In first approach, an object is given a name and page context is used to store this object. The page context is implicit object that can be accessed by tag handlers and JSP pages. The following command is used to access a shared object that has been given a name.
• In second approach of object sharing, all the inner tag handlers can access the shared object created by the outer enclosing tag handler. In this object sharing approach, a private name space is used for the object. So this approach will help to reduce the general naming conflicts. The following static method is called by the tag handler to access a reference of external tag in order to access shared object that is created by the external tag.Java Code:pageContext.getAttribute( name, scope );
The second way of getting the tag reference is to use the following method.Java Code:TagSupport.findAncestorWithclass( from, class );