This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes Custom tags to override jsp include action and @include directive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Custom tags to override jsp include action and @include directive" Watch "Custom tags to override jsp include action and @include directive" New topic
Author

Custom tags to override jsp include action and @include directive

sandeeprajsingh tandon
Ranch Hand

Joined: Mar 06, 2009
Posts: 70
Hi,
I think its a little strange requirement but
i have a 1000 jsp files that use jsp:include and @include for including other jsps.
Now, i want to make it possible for these functionalities to have dynamic jsp paths.
i.e jsp:include path="<%=DynamicPath%>/test.jsp", where DynamicPath will be available only at request time. This it seems is not possible as per the documentation of jsp:include
It would be too much work to go into 1000 files, change the path attribute to point to an expression and declare that expression in the jsp.

I thought i could create a custom tag for Myjsp:include where i could add path to the page attribute in my tag and then call the jsp:include from with in that.

Could anyone provide me a pointer on that?.

thanks
sandeepraj
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Possible for <jsp:include> tags.
Not possible for @Include directive which is resolved at compile time.

Consider using an EL expression such as ${dynamicPath} rather than a scriptlet expression.
I would try to stick with the <jsp:include> rather than customising it. Global search and replace refactoring tools should do a pretty good job in this case - provided its a relatively simple change.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

This is not a run-time problem. If the editing tools you are using make it hard to make these sorts of changes across multiple files, you need better tools, not a custom tag.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Custom tags to override jsp include action and @include directive