File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Question on JSP Tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question on JSP Tags" Watch "Question on JSP Tags" New topic

Question on JSP Tags

Manohar Karamballi
Ranch Hand

Joined: Jul 17, 2001
Posts: 227
Hai All!
I am using following Tag structure in my JSP page.
My question is it possible to return some return value from TAG1 handler class to TAG2? (Without storing return value in session or request object..) If this is possible pls let me know how to accomplish this? If not pls suggest me any other alternatives..

warm rgds

Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Hi Manohar,
There are a couple of ways in which your two tags can communicate without using the request or session scopes.
(1) <TAG1> could introduce a scripting variable into the page (through the PageContext.setAttribute() method), for subsequent use by <TAG2>.
(2) <TAG2> could use the getParent() method to get a reference to the actual tag handler class for <TAG1>. Once it has this, you can call any of the methods on the class as normal.
Although (2) is useful, it can increase the coupling between your tags. There are ways to reduce this coupling (for example using the findAncestorWithClass method on TagSupport) but I would suggest (1) as being the way to go.
Hope that helps.
Simon Brown
Co-author of Professional JSP 2nd Edition
[This message has been edited by Simon Brown (edited October 22, 2001).]
I agree. Here's the link:
subject: Question on JSP Tags
It's not a secret anymore!