• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

nested tag doubt

 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The below example is from the HFSJ book, chapter:10, page:539. I wrote both the file. I ran it , it gives me blank page in the output. I did not write TLD. Do I need to write TLD for that? If yes, how to write TLD for nested tag. The book have not mentioned any TLD for nested tag. Can anyone please help me?



-this is a Classic Tag Handler class
-------------------------------------------------------------------------------

<html>
<body>
<mine:nestedlevel>
<mine:nestedlevel>
<mine:nestedlevel />
</mine:nestedlevel>
</mine:nestedlevel>

</body>
</html>

-this is JSP
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you'll need to make a TLD. I remember feeling very intimidated the first time I wrote one but I after I did it I thought "I guess that wasn't so bad" and then I could copy and paste that TLD to make other ones!

You'll also need to reference the tag library in your JSP. You can look at page 542 for that.

You can reference page 467 for writing your TLD, but you'll definitely need to change the values of everything. Luckily, this example you're doing doesn't require you to map any attributes or functions, so your resulting TLD file will be quite small.

By the way, it's great that you're taking the time to try this example. I promise you'll really get a better understanding as a result.
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc, actually I did write one TLD after I did post & I got the result as same as book.
Can you explain how doStartTag() will invoke? I mean it invokes when most outer tag will invoke? And how the nestLevel is "0" first time? In short give me some flow of tag invocation & how doStartTag() will work?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start at the top of your JSP and read through it like a book.

Every time you reach the opening (start) tag of a custom tag, that tag's doStartTag method gets invoked.

The first tag you reach is on the outside of the other tags, so its nesting level will be 0.

Nothing tricky.
 
Do you want ants? Because that's how you get ants. And a tiny ads:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic