This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question on JSP Tags" Watch "Question on JSP Tags" New topic
Author

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.
<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

Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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).]
 
jQuery in Action, 2nd edition
 
subject: Question on JSP Tags
 
Similar Threads
Custom tags Qn in K &B pg 560
Doubt on Qno-:5 Pno-:487(HFS&JSP)
Doubt in HeadFirst question
How to get a SimpleTag Parent inside Classic nested Tag ( have a look)
lt body-content gt element in TLD