aspose file tools*
The moose likes Struts and the fly likes Disadvantages of Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Disadvantages of Struts" Watch "Disadvantages of Struts" New topic
Author

Disadvantages of Struts

dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Can anybody point out the disadvantages of struts? One that comes immediately to my mind is that struts only takes care of the controller and the view part of the MVC architecture. In comparison, Spring has its own MVC+webflow+Spring JDBC. Using Spring you need not even use EJB's. Will Spring replace struts as the industry standard for developing web apps?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Spring and Struts have both co-existed for some time, and I believe Struts has a much broader install base than Spring. The fact that Struts focuses on the View and controller and lets you choose your own model is not necessarily a disadvantage. In many cases, a model is already in place and you're just writing a front end to the model. In other cases, your company already had set procedures for creating a model that you have to follow. Some projects require an end-to-end solution, and others don't.

Probably the main "disadvantage" to struts is that it doesn't follow and event-driven model such as that used by Swing or other GUI creation products. Java Server Faces (JSF) does use a more event-driven and componentized model. If anything replaces Struts, it will be JSF. If you check out the Struts Home Page you will see that there is now a "Shale" framework that keeps some of the controller features of Struts, but uses JSF for creating the view.


Merrill
Consultant, Sima Solutions
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Merill dont you think Struts falls short when we talk about exception handling. For example in 90% of the cases when there is a JDBC exception you can do nothing but to forward to an error page, whereas in Spring the exception handling is taken care by the framework and you dont even have to write the try, catch and finally blocks in your code which makes the code cleaner. Also Spring provides a set of classes which directly map the rows in your database with your beans and return a List. ALso Spring advocates the use of interfaces when designing your classes which is a very powerful way of designing your applications. But when you extend your Action class your subclass cannot inherit features from other classes( interfaces being an exception ). Dont you think this could be a disadvantage?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There's no doubt that Spring has a lot of handy-dandy features that a developer could certainly find useful. If you like it better than Struts, use it.

We could waste a lot of bandwidth arguing back and forth about features, but I don't think there's much point in that.

I will say, though, that like the simplicity and elegance of the struts controller, and I don't mind taking control over my model code. I like having control over my own exceptions and deciding with ones to ignore, which ones to handle, and which ones to pass up to the caller. I don't understand your statement about having no options with JDBC errors. In my applications I can do anything I want with a JDBC error, including passing it up and letting struts handle it.

For those who prefer to have the framework handle exceptions, struts does have a mechanism for this. Just define the exception you want handled in the <global-exceptions> area of the struts-config.xml file. Then, code all methods (except for the execute() method of your Action class) to throw all Exceptions . If you don't catch the exception in execute(), Struts will handle it by forwarding to the specified page with the specified error message.

Even though Struts doesn't really have a framework for developing a model, you can plug in whatever model framework you like, including Hibernate, JDO, EJB, etc. You can even use Spring as your model framework and integrate it with a Struts front end.

The bottom line for me is that both Spring and Struts have their merits and one or the other may work better for a given project. I don't believe it's fair to state that Spring is better in all cases, nor do I believe Struts is in danger of disappearing or being replaced by Spring any time soon.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disadvantages of Struts