What Are the Benefits of Struts

16,769

Solution 1

Personally I myself prefer jsp/servlet but theoretically Struts has some advantages. Here are some of the advantages i know of, you might have mentioned them already, but i thought it would be better if i list all of them here.

  1. Centralized File-Based Configuration. Struts values/mapping are represented in XML or property files. This loose coupling means that many changes can be made without modifying or recompiling Java code, and that wholesale changes can be made by editing a single file. This approach also lets Java and Web developers focus on their specific tasks (implementing business logic, presenting certain values to clients, etc.) without needing to know about the overall system layout.

  2. Form Beans.

  3. Bean Tags. Struts provides a set of custom JSP tags that let you easily output the properties of JavaBeans components.

  4. HTML Tags. Struts provides a set of custom JSP tags to create HTML forms that are associated with JavaBeans components. This bean/form association serves two useful purposes:

    • It lets you get initial form-field values from Java objects.
    • It lets you redisplay forms with some or all previously entered values intact.
  5. Form Field Validation. Struts has a robust, extensible validator that can be used to uniformly validate your form fields. This validation can be performed on the server (in Java), or both on the server and on the client (in JavaScript).

  6. "Plumbing code" contained within the Struts framework. Mapping HTTP request parameters to Java objects is handled by Struts, for example. You don't have to do it. This allows you to focus more on the domain problem instead of building infrastructure.

  7. Good documentation & plenty of books. If you have to leave the project and/or someone else has to maintain it then using a well known and well documented framework will make that job much easier. A homebrewed framework just can't match that.

  8. Broad user testing. Since Struts is used in plenty web-apps the framework will get looked at by many more eyes than anything you could write alone. Usually, but not always, that means any problems you have will have been seen by someone else (and hopefully resolved) first.

Solution 2

Large knowledge base. I agree that this perhaps isn't as valid as it used to be but Struts has been used in a lot of projects over the years. From a maintainability point of view using a well known framework makes it easier for other people to work on your application and also help build your own resumé for the future. Right now most development is either in the component based space (like JSF, wicket, tapestry) or in the rails-like space (like rails, grails, lift) but the struts arcitechture is still in use and valid.

You didn't say if you develop in a corporate environment or not, for a personal project perhaps the maintainability issue isn't that much of a problem.

If you decide that struts suits you well you could also have a look at stripes, a struts-like framework that's based on the same concepts but is less verbose when it comes to configuration with more sensible defaults, less xml and support for annotations.

Solution 3

I totally agree with your points about Struts - personally I think its time has come and gone.

I went off Struts in v1 (which I believe is nothing like the latest versions) because the form beans where just added boilerplate code to write.

Since then most applications I've worked on are using Spring as the dependency injection framework, which has made Spring MVC the natural choice - it's simple, straight forward and minimal.

Solution 4

Not just for Struts. But some points to consider for using a framework:

  • Standarization.
  • Specialized IDE or plugins for your favourite IDE.
  • Portability. For example, someone can develope a portlet for integrate your existing struts application in a portal server.
  • Internationalization.

The most important for me:

  • You dont have to worry about the issues on the struts code, just upgrade.
  • You can focus your work in business logic.

Solution 5

I think your feeling about removing Struts is a sound and understandable reaction. Struts just doesn't seem to do very much for an application.

Share:
16,769
ZZ Coder
Author by

ZZ Coder

A coder trying to beat a friend on Stackoverflow reputation.

Updated on June 04, 2022

Comments

  • ZZ Coder
    ZZ Coder almost 2 years

    I recently added Struts 1.3 to my application on Tomcat. Here are my observations,

    1. MVC. Servlet/JSP does this fine for me, where JSP is the view and servlet is the controller. I don't see any benefit to get the mapping from an XML file since our mapping is very static.
    2. Action Form. I can see some benefits of action form but not huge.
    3. Tags. I already uses JSTL and don't see any advantage using Struts tags.

    So I am thinking about removing Struts. Anyone can think of any other benefits I might have missed?