• Post Reply Bookmark Topic Watch Topic
  • New Topic

variables in included file  RSS feed

 
Justin Carter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is regarding variables used in a banner or footer file, included using the <%@ include %> directive. I want to make sure that these variable names are unique, to ensure that the parent jsp (or any other included file) does not also use the same variable name, which would throw a compiler error.

Also, it is my understanding that the <%@ include %> method is the best for banner or footer files, since the included files are not going to change a whole lot. The <jsp:include> method (which includes the file at run-time) would take care of the need for unique variable names, but would not be as efficient as the <%@include%> method.

My first thought was to add a descriptor to the end of all of the included files' variable names, such as "_banner" or "_footer", but I am not sure that that is a good practice. Any thoughts?
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Postfixing looks good option but keep in mind that business logic should be part of service class (java file) and not jsp. and scriplets are past now.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most modern approach would be to use neither of the include mechanisms, but to use a tag file.

And yes, scriptlets are now 8 years out of date.
 
Justin Carter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your replies. We have been working to get our old Model 1 pages up to date, so I really do appreciate your comments.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!