File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL vs. Struts taglib

 
Ali Ekber
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • 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.
     
    Brent Sterling
    Ranch Hand
    Posts: 948
    • 0
    • Mark post as helpful
    • send pies
    • 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
    • 0
    • Mark post as helpful
    • send pies
    • 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
    • 0
    • Mark post as helpful
    • send pies
    • 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.
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic