• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to generalize multiple *.jsp doing the same thing ?

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Tiles Definition that uses many child JSP files doing the same thing, which is listing elements in their respective Collection.

For the 1st child JSP, it contains code like:
<%
Collection c = (Collection)request.getAttribute("localElements");
%>

The 2nd child contains:
<%
Collection c = (Collection)request.getAttribute("domesticElements");
%>

Other children get other collection with different attributes. All the children have the same code of displaying all the elements in the Collection by iteration.

It doesn't take an Einstein to know that this is not good. A lot of duplicate codes in different JSPs exist just because each child JSPs need to iterate different collections.

Any advice of how I could extract the common codes such that there will be no duplication in the JSPs?

[ February 25, 2005: Message edited by: Ken Loh ]
[ February 25, 2005: Message edited by: Ken Loh ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend building your own Tag. They are built for this sort of work.

Best of Luck,

Nate
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic