aspose file tools*
The moose likes JSP and the fly likes JSP Tag that contains result of another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Tag that contains result of another" Watch "JSP Tag that contains result of another" New topic
Author

JSP Tag that contains result of another

Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
I have a method getURL() in a POJO FOO that does:



In another method, I have code that does:


In my Custom Tag I am doing:


The problem is that the Tag is not evaluating the contents in getURL() but is representing it "<customTag><% mywriter.write(out); %></customTag>"
How can I make the custom reevaluate the contents of the other tag as well?
Thanks in advance.


Never be satisfied with anything less than the best and you will surely pass the test...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

You can't. Custom tags are evaluated and translated into code during the translation phase of the JSP life cycle. Your call to getURL() is not executed until the execution phase.

In order to cause a custom tag to be evaluated it must be part of a JSP. You might want to investigate the request dispatcher include mechanism, or tag files (if you are using JSP 2.0).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Thanks for the answer. As I had mentioned, I have a Cutomer tag <tag1>. In the tag I am trying to write to the stream another tag, <tag2> with out.write("<tag2");

This does not seem to work even if the page references the tld that contains the tag. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

No. As I said, any custom tag that you emit as text will remain just that: text.

If you want to dynamically include a custom tag in another, you need to put the nested tag in a JSP file that can be included via the request dispatcher.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

Here's something that I wrote that's somewhat related and may give you some ideas.
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Hi Bear. I liked what you wrote and am trying to work with it. I was if it could be posssible to include different taglets on the same page with pageInclude? For example,


If not can you suggest a way this could be accomplished?

Thanks....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

Sure, why not? It's all just Java code.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

Btw, you can make all this much simpler by using tag files under JSP 2.0.
 
 
subject: JSP Tag that contains result of another