• Post Reply Bookmark Topic Watch Topic
  • New Topic

performance effect of jsp:include

 
sirishree priya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a jsp page of 1000 lines.Now if I split the code and use 50 jsp:include will it effect the performance of the page or its the same say having single page of 1000 lines.
Thanks in advance
Priya
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp:include is done at runtime.
Does the page need to determine at runtime what page to include?
If not, then use <%@ include file="..." %> instead. This is done at compile time and therefore would have no effect on runtime performance.
[ July 20, 2003: Message edited by: Ron Newman ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or... if the majority of those 1000 lines are Java, factor the code out into beans, helpers and custom tags. Your JSP pages are best primarily composed of HTML markup with just enough Java code to perform any display-related code. Anything else is best removed from the page.
hth,
bear
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a large amount of java code and move it to custom tags will it have a perfromance improvement? I thought custom tags are a performance penalty which you pay for convenience of using them....
Vasu
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should make very little difference in response time. However, by getting your code out of JSP and into helper classes you will probably find it much easier to optimze the code and to maintain it in the future.
The very idea of maintaining a thousand lines of JSP makes me shudder.
Bill
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sirishree,
Splitting your jsp into 50 jsps and including them in the main jsp is not any different from having a 1000 line JSP as the jsp compiler includes them anyway. Your jsp looks neater. But as pointed out by someone here, you should move all your java code out and make the jsp look like a HTML. Best way to do it is using custom tags. A good side effect of doing it is these custom tags can be reused by your other applications. Using JSTL makes your job of writing custom tags still easier.
Hope this helps.....

Vasu
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priya,
I would go ahead and use @include instead of JSP include. The reason is @include is compile time and is much faster in terms of performance than out dynamic jsp:include. I have programmed on JSPs for the last 3 years and have rarely( saying never wont be an exageration ) come across the scenario where a jsp:include HAS to be used.
Multiple JSP pages ensures cleanliness, but it really is tedious to remember which of those 1000 lines are in which page.
If the scenario demands go ahead and use @include.
For development and testing u can use jsp:include. Hoever when sending the war/ear to the client make sure u change the tags to @include. I do this because if u use @include at the time of development/testing u have to keep clearing the cache, a tedious task, aint it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!