• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

servlet versus a custom tag

Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the need to take an xml data source and do a transform with an xsl template.
I have written it as a servlet and as a custom tag. Both work.
My question is, when would be best to implement it as a servlet and when would it be best to implement it as a custom tag?
The servlet is currently being used by multiple sites that need the transformed data (we return the data in html or wml format as requested).
The custom tag is a proof-of-concept implementation. I wasn't quite sure how to do it and wanted to see if I could. It would (yes, life is subject to change, but for this round...) always be called from a JSP.
Does this seem right? Are their resource issues to take into account?
Any insight is appreciated,
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sharon,
I think you kind of answered your own question believe it or not. From the perspective of a JSP/Servlet application, if the required transformation is always going to be called from with a JSP, then a custom tag is a better implementation. What you seem to be doing is formatting data for display. Sticking to the Model-View-Controller pattern (v2) this is a View-centric task and a View-centric solution would therefore be best (as opposed to the Controller/servlet which should simply dispatch requests to the appropriate View). Writing it as a custom tag better follows the pattern and allows for greater ease of portability and reuse. Also your JSP developers (in my case and probably yours this is you) would be able to use the tag wherever they needed. These are all advantages of a custom tag that I'm sure you're familiar with. As far as performance considerations... I can't think of any... the JSP gets turned into a servlet by the servlet container, so I'd imagine that performance would be the same. On the other hand, I can imagine that the presence of an intensive tag could make it appear to take longer becauce the screen make take longer to draw.
That's my two cents.
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic