• Post Reply Bookmark Topic Watch Topic
  • New Topic

el attribute inside a custom tag body is accessible out side the scope of the custom tag?  RSS feed

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unable to make sense of this code

I have a custom tag handler SimpleTagTest3 the code looks like



The tld file is



When i keep <body-content> as scriptless it displays



But when is use body content as tagdependent it displays
[/code]
The message is ${message}

This message is set within the tag
[/code]
I am unable to understand why so. And also in both the cases I am able to access ${message} out side the scope of the custom tag handler that I have created. Don't you think that is wrong?

Please help me understand the concept.
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

From my understanding, "tagdependent" is used to denote that the body of the tag is to be evaluated by the Tag-Handler alone and not the JSP engine. (or call it JSP container).
So that would mean that ELs are not processed at all by the JSP engine.

In the case of 'scriptless', after the tag handler sets the attribute, the JSP engine evaluates the EL and displays the corresponding "This message is set within the tag "

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK understood the tagdependent.

but what about the ${message} that is withing the context of custom tag handler that I have created. If I use it out side the context of <myTags:simple3> then it should not diaplay anything.

This was what i found in SCWCD Head first Book .${message} is set in the doTag();
At the point where the tag is invoked,
“message” is NOT a scoped attribute!
If you took this expression out of the
tag, it would return null.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you're setting a page-scoped variable and then you are surprised when it's available in its own scope? Why? What's going to make it magically disappear?
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK I got you point. So it will display the ${message} because it is page scoped. What does he mean (the author of headfirst) when he says it will display it as null. In which situation will it display null
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!