• Post Reply Bookmark Topic Watch Topic
  • New Topic

Seperate JSP versus common utility java class

 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I am working on Servlet/JSP project. There are large no. of jsp pages. A common set of methods get repeated in all the jsp pages. Now my concen is to separate out the methods in a file and then use it in jsp page.
I have taken out the methods and created a separate jsp page and have included it in all the required JSPs. The other approach which comes to my mind is to create a simple java class with the common utility and importing it in JSPs.
Kindly suggest me the right path to follow, taking into consideration that we take up the optimized solution.
Please reply ASAP since it is quite URGENT !
Thanks in advance.
Regards.
 
parag Chatterjee
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You second approach of Java class is a more standard approach.you create taglib for the class and use as common tags in all jsp pages.
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

Well, kindly comment on the performance on these approaches.
1. Using 'include jsp'
2. using 'taglib'
3. creating a seperate utility class with the required methods and 'import' it in the JSP pages.
Thanks again!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taglib and auxilliary class are functionally equivalent and should be faster than include due to include having to invoke another JSP. However I doubt your users could tell the difference, so you should go for a design that is easily maintained.
Bill
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur suggestions.
I have created tags and using it im my project.
Thanks again.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and if you subscribe to the practices around writing your unit tests in code (e.g JUnit) then check out TagUnit for unit testing custom tags.
Simon
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!