views:

716

answers:

7

Once upon a time, Struts was the default choice for a Java web framework.

I have no data on this, but I imagine that Struts2 is currently widely used for legacy reasons, only because former Struts projects have been migrated to it.

Is Struts 2 really the best choice for a new project? What other web frameworks out there are most popular and clearly a better choice for a brand new project?

Looking for some suggestions here from people with real world experience on the current crop of java web frameworks. Please only answer if you have hands on experience.

+2  A: 

I much prefer Spring's MVC. I think it's a better design than Struts, and it comes with all the other Spring machinery that's so helpful.

duffymo
Struts2 integrates perfectly with Spring. The "Other Spring Machinery" can be used just as easily with either framework.
leonm
Yes, exactly. But if you choose Struts2 without Spring, you don't get any of the that "other machinery". If you choose Spring without Struts2, you've got everything that Struts2 provides and much, much more. You make it sound like the two are equivalent - they're not.
duffymo
+2  A: 

We were able to migrate from a homegrown MVC to Stripes with minimal effort. Because it is very extensible, we were able to leave most of our code intact and just override the default behavior where necessary. Additionally, the maintainers are very active on IRC and can usually provide an answer to a question immediately. We have also developed a few webapps from scratch using Stripes.

jt
+5  A: 

It is not trivial to migrate Struts1 app to Struts2. I don't think Struts2 in being used mainly because of upgrades from Struts1.

But to describe why we picked Struts2 I have to describe how we discarded the rest:

We discarded JSF because it was simply too hard to work with. And the majority of components didn't act like real websites - for example opening multiple tabs will confuse a lot of components because they store state in the session. Have a look at http://ptrthomas.wordpress.com/2009/05/15/jsf-sucks/

We discard Tapestry because the learning curve is steep and it is generally a big PITA http://stackoverflow.com/questions/1303438/why-did-you-stop-using-tapestry/1304575#1304575

Wicket and Stripes looked promising but not quite mainstream enough. We weren't entirely ready to back on of those horses in the long term.

It became a toss-up between Struts2 and Spring MVC. Struts2 has really good support for Spring. In the end most developers felt more comfortable and productive with Struts2.

The framework is relatively simple in its design and it plays well with others - i.e. Spring, Hibernate, JQuery/JSON was easy to integrate with.

leonm
+1 for why nots - too few of these generally
Thorbjørn Ravn Andersen
Wicket is good if you like OO. It is very Object Oriented in nature, and I hate heavy OO, so I wouldn't recommend wicket
bugspy.net
A: 

Grails is a massive player in this space. It uses Spring/Hibernate, however it is debatable if it meets your requirements since it is Groovy, not Java.

That said, Spring MVC is definitely worth exploring. It is a leader in the pure-Java area, and with Spring 3, reflects some influence by Grails.

Michael Easter
+1  A: 

I imagine that Struts2 is currently widely used for legacy reasons, only because former Struts projects have been migrated to it.

I very much doubt this. Struts 2 was completely different to Struts, and was based on an existing framework called WebWork. WebWork was quite nice, but wasn't popular, and so it made sense to merge it with the Struts brand.

So I'd say it's unfair, if understandable, to tag Struts 2 with the "legacy" label, since it's not. There are, however, many other frameworks that are better, and so I'm not really sure why anyone would use it, given the choice.

skaffman
All is fair in java web framework wars :) I know a lot of (pointy haired boss driven) teams who chose Struts2 because the name misled them into thinking that it would be a smooth migration from Struts1 and there would be no need to re-learn much.
Peter Thomas
IMO it was very disingenuous of the Struts 2 team to do this. It really should have been called WebWork 3, not Struts 2, but then noone would have used it.
skaffman
+2  A: 

If you want something simple use Stripes. If want something modern Wicket is the best option. If you like the RoR philosphy you can try Grails. People like to bitch about Java, but is the plattform with more choices IMHO.

Omat Gomez
A: 

Pay attention to http://www.hybridserverpages.com/

It is pure Java. Five times simpler than say Wicket or JSF (described on less than 10 pages) but AT LEAST of the same power.

Does not even make sense to compare to Struts...

Dima