View RSS Feed


Cooperating Tags in JSP

Rating: 1 votes, 1.00 average.
, 07-07-2012 at 07:55 PM (1133 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.
Java Code:
pageContext.getAttribute( name, scope );
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:
TagSupport.findAncestorWithclass( from, class );
The second way of getting the tag reference is to use the following method.
Java Code:

Submit "Cooperating Tags in JSP" to Facebook Submit "Cooperating Tags in JSP" to Digg Submit "Cooperating Tags in JSP" to Submit "Cooperating Tags in JSP" to StumbleUpon Submit "Cooperating Tags in JSP" to Google