aspose file tools*
The moose likes JSP and the fly likes Why is custom tag not producing any output? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Why is custom tag not producing any output?" Watch "Why is custom tag not producing any output?" New topic
Author

Why is custom tag not producing any output?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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

Joined: Jan 10, 2002
Posts: 61202
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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

Joined: Sep 29, 2008
Posts: 12617

But it does support "scriptless" bodies--isn't that good enough?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

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

Joined: Jul 02, 2008
Posts: 436
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 10, 2002
Posts: 61202
    
  66

You can lead the horse to water ...
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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, -
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is custom tag not producing any output?