Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we reuse JSP chunk defined within JSP Page; without creating another JSP file?  RSS feed

 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 14 piece of code at different places in JSP which is getting repeated at 14 places in JSP:



Requirement to define above chunk at one place and reuse 14 times.

I know i can create its .JSPF and include it again using <% include.

But we want to avoid this as i have to apply same for other chunks too and i am told not to make much files.

So is there any way to define JSP chunk inside page (somewhere in head or foot or in HTML element) and reuse at multiple places on load?

Please consider if we use For Each like:
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the prime use case for a custom tag rather than a JSPF include.
You could then add parameters to the tag for "re-use" - you should only need a few tags to accomplish what you want.
I would suggest creating as .tag files to start with.


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!