Forums Register Login
Question on JSP Tags
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

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).]
This is my favorite show. And this is my favorite tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java

This thread has been viewed 669 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 20, 2019 06:23:54.