I hear a lot about Struts and Struts 2(as well as other frameworks) and I know some people like frameworks very much and others don't care for frameworks at all. I've just started web application development in the last 6 months. I've learned MVC using JSP, servlets, and beans. What advantages does Struts 2 offer over JSTL and EL?
I'll respectfully disagree with Jeanne on one point: she makes it sound like Struts has no penetration into the JSP/view layer. My experience with Struts 1 is that in order to use it effectively, it requires serious incursions into the JSPs with lots and lots of custom tags.
Struts 1 does not require incursion into the view layer, the taglib provided with the framework is merely convenient. You can do anything with straight JSP that you can do with the Struts taglib as long as you know what you're doing.
Originally posted by Schevus Osborne: Struts 1 does not require incursion into the view layer
Well of course one could include all the Struts stuff in a project and then ignore it -- but then why bother using it in the first place? That's why I used the word "effective". Without page incursion, many of the Struts 1 value propositions are unused. For example, without using the form element tags, there can be no automatic population of the form elements from the Form implementations.
There's all the front controller implementation that you can use outside the pages, but if that's all of Struts that's going to be used, there are much simpler solutions.
Again, I can't speak to Struts 2, but Struts 1 was conceived and implemented in an age where JSP was in its infancy. Much of what Struts 1 was intended to achieve has now been provided by the modern Servlet and JSP Specifications along with the JSTL and EL. Trying to mix them usually results in a bit of a jumble.
How Struts 2 fits into that scenario, I can't say. (But a brief look at the table Joe linked to has me scratching my head wondering why they adopted a proprietary expression language).
Unless I miss my guess, Bryce was primarily interested in how Struts 2 affects how JSP pages are written. Anybody have insight on that? [ January 30, 2008: Message edited by: Bear Bibeault ]
Unless I miss my guess, Bryce was primarily interested in how Struts 2 affects how JSP pages are written. Anybody have insight on that?
Unfortunately, I haven't used JSTL and just picked up Struts 2, but I will tell you that like 1.x, Struts 2 has a tightly-integrated tag library to accomplish the same tasks (form elements, logic, collection iteration, etc.) As for using OGLN, perhaps they needed it to support the Value Stack, which is where the framework stores the action, request, response and anything the user cares to add.
Originally posted by Bear Bibeault: I'll respectfully disagree with Jeanne on one point: she makes it sound like Struts has no penetration into the JSP/view layer. My experience with Struts 1 is that in order to use it effectively, it requires serious incursions into the JSPs with lots and lots of custom tags.
First of all, I disagree with myself. I meant to say "Struts (1 or 2) is also used in the servlet/form/action (Java code) layer. They serve completely different purposes." The difference that one missing word makes! I certainly didn't mean that Struts can't penetrate into the view layer. I meant that JSTL/EL doesn't penetrate into the servlet layer.
I do think it is possible to use Struts with JSTL/EL. It probably depends on how you use Struts. Just as it depends on how you use servlets to avoid custom tags in the JSP. We use Struts more for the flow. The action/model has most of the custom stuff.
WebWork is an old framework, I think they started it in 2001. In that time, JSP EL wasn't born yet (I hope I'm not wrong), so they need an EL to serve the framework (OGNL). It is now possible to use JSTL & JSP EL instead of OGNL in WebWork2 (aa, I mean Struts2). WebWork2 team declared that they would like OGNL in favor of JSP EL but only if there is no power loose.
Joined: Nov 19, 2007
The fact that EL doesn't go into the servlet is a great asset, at least in my thinking. This reinforces the MVC pattern by helping to keep each piece separate from each other.
Correct me if I'm wrong, but with the introduction of the newest JSTL and EL, Struts has become more of a competing framework instead of a supplemental framework as it was when it started and the intentions behind it.