aspose file tools*
The moose likes JSP and the fly likes JSP include vs TAG Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP include vs TAG" Watch "JSP include vs TAG" New topic
Author

JSP include vs TAG

Nigel King
Greenhorn

Joined: Mar 03, 2006
Posts: 29
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nigel King
Greenhorn

Joined: Mar 03, 2006
Posts: 29
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.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP include vs TAG
 
Similar Threads
jsp:param
jsp actions + expr values
A problem about the usage of tag jsp:param
jsp:param and c:param - are they same ?
nested:iterate and the size of the collection