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

Why is custom tag not producing any output?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have created a custom tag. The code follows. Despite the fact that I verified through log statements that the doAfterBody is called and returns a value, nothing is output to my JSP page. Any ideas for troubleshooting further?

Java class ...


JSP invocation:


TLD:


Thanks, - Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why aren't you basing your tag on SimpleTagSupport rather than "classic" BodyTagSupport.


(where "classic" means "we didn't deprecate it, but it's just too complex and cantankerous to deal with, so we completely replaced it with something else").
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SimpleTagSupport doesn't support custom tags that have JSP body-content. I am open to another implementation but the question is still unanswered.

- Dave
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it does support "scriptless" bodies--isn't that good enough?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2413
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,

Why are you overriding the setBodyContent() method, this is not needed. Furthermore the body content is usually written to the page like this:

Regards,
Frits
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To David's question,

I can't guarantee that the body-content will not contain EL expressions. However, even when it contains text (per the example in the original post)å



I'm getting the error that follows ...




The new code I have is

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yeah; you'd have to change the TLD to be "scriptless", not JSP. But I think one or both of us is missing something--that doesn't mean the body can't contain EL or JSP:TLD (probably screwed up--more or less from memory and crappy examples on web)Tag implOutput
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any case--why not use JSP 2.0 JSP-based tags? For something as simple as this that isn't really doing much it sure seems easier.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can lead the horse to water ...
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David, Per your suggestion (thanks for the helpful example), I changed the body-content to "scriptless" instead of "JSP" and everything worked.

I actually don't know anything about JSP 2.0 tags so didn't know to ask about them. I will see how they can be used with reference to my example.

Thanks, -
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic