Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP include vs TAG

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building a web site where each page is essentially a collection of component JSP pages. One of these components takes an image, some text, and a title all as <jsp aram> and it is called many times - with slightly different <jsp aram> - on the same page.
After looking into tag libraries it seems I could build my own tag to do the same thing.
What would be the pros and cons of changing from <jsp:include> to a tag?
I'm completely happy with how it runs at the moment but if it were to give me a performance improvement I'd look into it.
Thanks in advance.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds as if you are making all of your structuring decisions based upon anticipated performance rather than what makes the most sense to the structure of the application.

The question you should be asking yourself is whether the components make the most sense to be included via the inclusion mechanism, or as tags. Then make your decision based upon the answer to that question rather than some probably specious performance consideration.
 
Nigel King
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first proper Java web site and I'm conscious that much of my methodology may be the "old way of doing things".
I've also read many times that a good JSP page has little or no actual Java code in it : tags invisibly handling much of this. I'm just continually trying to improve it and was wondering whether the consensus of opinion was that a tag would be considered an improvement over a jsp include.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say, given your description that a tag would be more appropriate than a jsp:include in this case.

A <jsp:include> calls requestDispatcher.include(request, response) which invokes another servlet on the container. Presumably a custom tag might be a little more efficient, as it doesn't invoke a seperate servlet, but I don't think the difference would be enough to matter.

If you have a JSP 2.0 container (eg Tomcat 5) it should be a very simple matter to convert the file you are including into a .tag file - pretty much just a copy and paste job.
    Bookmark Topic Watch Topic
  • New Topic