Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JSP Includes

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP file which includes a lot of JSPs for purposes of modularity. But I am having to include the taglibs and javascript files that we use in every JSP file that has been included. That way , I am import files in every JSP file. I wanted to know if there is a way to import all of these files in one location and make them available to all the JSPS
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kartik krishnanand:
I have a JSP file which includes a lot of JSPs for purposes of modularity.


If you are using JSP 2.0, tag files would be a better mechanism for this purpose.

But I am having to include the taglibs and javascript files that we use in every JSP file that has been included. That way , I am import files in every JSP file.


If you are worried that this is going to cause any sort of a performance issue, rest easy. The "import" is a translation-time artifact and will not affect run-time performance.

However, it is a pain in the neck, as well as error-prone, to copy the declarations on each and every page. You may want to explore the concept of a JSP prelude.

More information can be found in the JSP Specification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic