Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Seperate JSP versus common utility java class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for ur suggestions.
I have created tags and using it im my project.
Thanks again.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic