• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSP Tag that contains result of another

 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's something that I wrote that's somewhat related and may give you some ideas.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, why not? It's all just Java code.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Btw, you can make all this much simpler by using tag files under JSP 2.0.
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic