• 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

JSTL vs. Struts taglib

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone give a brief reasoning why we would one over another? I know there is a forEach in JSLT and logic:iterate in Struts which are compariable, but when to use one over another. Thanks.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally prefer to use JSTL whenever the same function can be performed by either a Struts tag or a JSTL tag. My reasons for doing this are:

  • JSTL tags are more standard. Any Java EE developer worth their salt knows these tags, but Struts tags are not part of the standard.
  • JSTL tags are more powerful. For example, it's easy to do and/or logic in JSTL tags, but not in Struts tags.


  • I do make heavy use of the <html:xxx> tags, though, as there is no equivalent of these in JSTL.
     
    Ranch Hand
    Posts: 948
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I have to admit that I use the logic tags more that I probably should. Mostly because that is what I started with when I got into Struts development. I don't do much JSP development these days and I guess nobody on the team has stepped up to say that we need to use JSTL more.

    I am curious. Are there logic tags that do not have equivalent JSTL tags or are there logic tags that are more convenient to use? Could we abandon the logic tags? If we use JSTL heavily, should we also be using struts-el? (sorry, not trying to hijack your thread)

    - Brent
     
    Merrill Higginson
    Ranch Hand
    Posts: 4864
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    About the only <logic:xxx> tags I use are <logic:messagesPresent> and <logic:messagesNotPresent> since these deal with Struts-specific messages, and there is no equivalent in JSTL. For all the others, JSTL is eaiser to use and more powerful

    The same is mostly true of the <bean:xxx> tags, whith one notable exception: There is no equivalent to the <bean:size> tag, and that one comes in handy.

    Regarding the struts-el tags: Since the web tool I'm using handles regular struts tags better than struts-el tags, I tend to use the regular ones more. However, when I need to use a run-time expression in a Struts tag, I'll use struts-el.

    The trend is toward "scriptless JSPs", and while I'm not fanatical about it, I try to keep scriptlets out of my JSPs as much as possible, and one way to do that is to use struts-el.
     
    Merrill Higginson
    Ranch Hand
    Posts: 4864
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't believe there is anything comparable to the nested tags in JSTL. As I see it, the only reason for using them is if you're using indexed properties and want Struts to handle the naming of indexed properties for you. I don't generally use the nested tags, as I prefer to handle the naming of indexed properties myself.
    reply
      Bookmark Topic Watch Topic
    • New Topic