Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

taglib custom tags

 
Stefano Cazzola
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody.
I'm new to JSP programming, even if I have a fair knowledge of Java.
I would like to use custom tags, and to nest them into each other attributes... something like that



I've seen many tags used like this (as c:url for examble) but I'm not able to do this.

Can anybody help me?

Thanks,
Stefano
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you haven't seen that. You cannot use a custom tag as an attribute value of another custom tag.
 
Stefano Cazzola
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you are right. I didn't see that. I saw (and used)

I supposed it was a standard behavior and that it was possible also with custom tags.

However I found a solution (quite verbose but effective) to use the output of a custom tag as value for an attribute of another custom tag


Stefano
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefano Cazzola wrote:I supposed it was a standard behavior and that it was possible also with custom tags.

Ahhhh! This is an important distinction. HTML tags, and all other client-side markup is just template text to the JSP engine. It could be the Magna Carta as far as the JSP engine is concerned -- it doesn't apply any semantics to it whatsoever.

However I found a solution (quite verbose

The more standard way is to store the output of the custom tag in a scoped variable, and then use the EL to supply that value as the attribute value.
 
Stefano Cazzola
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear!
I'll follow the standard way, then.

Bye,
Stefano
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic