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.
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.
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.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com