[Logo]
Forums Register Login
Question on JSP Tags
Hai All!
I am using following Tag structure in my JSP page.
<TAG1>
<TAG2>
<b>hello</b>
<TAG2>
<TAG1>
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..

TIA
warm rgds
Manohar

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.
Regards
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
[This message has been edited by Simon Brown (edited October 22, 2001).]
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 633 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 23, 2018 05:42:56.