aspose file tools*
The moose likes Struts and the fly likes Struts 2 vs. JSTL and EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 vs. JSTL and EL" Watch "Struts 2 vs. JSTL and EL" New topic
Author

Struts 2 vs. JSTL and EL

Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
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?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29241
    
139

Bryce,
JSTL and EL are only used in the JSP layer. Struts (1 or 2) is used in the servlet/form/action (Java code) layer. They serve completely different purposes.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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.

I have no experience with Struts 2.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Bear,
My reading of Struts 1 has given me the same impression. I had yet to hear of Struts 2. Is his like a new version of struts? Or are they completely different?
Schevus Osborne
Greenhorn

Joined: Jan 21, 2008
Posts: 7
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.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

Originally posted by Bryce Martin:
I had yet to hear of Struts 2. Is his like a new version of struts? Or are they completely different?


They are very different. See this comparison.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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 ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

Originally posted 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.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29241
    
139

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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Originally posted by Jeanne Boyarsky:
The difference that one missing word makes!
Ah yes, it turns out that we are in violent agreement.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

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.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 vs. JSTL and EL
 
Similar Threads
How to make EL work with Struts???confused:
How to use Struts-EL tag in web application ??
Struts Survival Guide
Java EE 5/6 web application architecture - aaarrgghhh!
Struts 2 vs JSF or Velocity