Announcement Announcement Module
Collapse
No announcement yet.
Spring vs. Struts vs. JSF Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring vs. Struts vs. JSF

    Maybe someone could tell me this and save me from digging through documentations to find the answer. Can I replace JSF, Struts with Spring? Can I create a Spring portlet? Is there a document out there comparing JSF vs. Spring or Struts vs. Spring? I have only used Spring in the combination with Hibernate to manage session.

    Thanks so much for your answer.
    C.

  • #2
    In the context of your question, I assume you are refering to spring MVC. Spring itself is more than a MVC framework. Spring is made up of many components, main component being the Core Container (Beans, BeanFactory, ApplicationContext, etc) that provide the Dependency injection via a lightweight container, and the rest of the components (eg. AOP, Transaction Management, etc. ) are built around it.

    The idea is that Spring allows you to use what ever you want, to mix and match its components easily. So in effect, you can use Spring to do your Transaction Management and AOP but choose to use Spring MVC, Struts or JSF as your MVC framework.

    With that understood, let's now compare apples to apples
    Spring MVC vs Struts vs JSF.

    I wouldn't get into a religious discussion here on which is the best, but I'll simply lay out the facts.

    Struts
    - struts is going to become obsolete very soon. It is one of the first MVC framework, and hence very cumbersome and "backward" by today's standards (because of the need to maintain backward compatibility, they can't rearchitect it the way it should be done). It is confirmed that there won't be a Struts 2. The struts ppl are starting a new project under struts-shale that is build upon JSF totally different from struts. Struts itself will only remain and be maintained by those still interested in doing so, while to main ppl are concentrating on shale now. Shale currently is still too young, with only 1 release as of this writing. This version is considered "relatively stable" and only for early adopters and ppl who are interested in evaluating it (See shale website).

    Spring MVC
    Similar to struts concept, but much more elegant, well thought and do away with a lot of Struts' shortcomings and cumbersome nature. like struts, it is also build upon the model 2 architecture.

    JSF
    JSF is an official standard from sun. It is a Specification, hence will have lots of implimentations. It is also now part of the J2EE specs. Therefore any vendor that wants to be J2EE compliant is forced to come out with an JSF implimentation and provide support for it. In other words, there will be lots of competition to provide the best and lots of choices. Currently, the 2 main implementations are the sun's JSF RI (Reference Implementation) and Apache's MyFaces. JSF has a totally different architecture and programing model, abandoning the classic model 2 architecture. Some ppl say that it is now a true MVC model and model 2 being a watered down MVC. It adopts a new model similar to that of ASP.net, which makes it easy for WYSIWYG GUI builders to generate pages for you (yes like M$ visual studio). Its programming style will be similar to Swing. You now put listeners on links and buttons to trigger events and arrange your layout using layout objects (for example grid layout objects like in Swing. It will generate tables and arrange stuff for you). It has much less configuration than struts even if you hard code JSF without GUI builders(done correctly of course). It feels very much like M$'s model only thing is that you won't be stuck with one single implementation/vendor/company. If an implementation is lousy, choose a different verdor's. You won't forced to live with a single company's ugly, messy and lousy generated code. You have choices.


    I've used all 3 frameworks before and my recommendation:

    Do not to use struts for new projects. Almost anything is better now adays. Only exception being you have ppl already trained in struts and is a risk to adopt new stuff.

    For Spring MVC, there is still relatively few professionals that had taken that up, althought more and more ppl and coming aboard, so something must be right about it And I think its cool too. So talent may be hard to come by, unless you train them and let them learn.

    For JSF, well....its official, its sun, its a J2EE spec, all vendors will be forced to have a stake in it... it will be forced to be "successful" with mass adoption. Shale will be build around it. If it will be a good/useful/productive model remains to be seen and proven and there's no point arguing about it now. So far, after using it, it seemed to be pretty good. The only problem is that its also quite hard to find ppl well trained in it and it is a bit harder to learn as it departs from conventional model 2, so there's a few mindset that needs changing. (Well the first time I did dependency injection and AOP, it feels the same way)

    You have to make your own decision on what to use. If you believe JSF will be another EJB or if you think JSF will be THE standard of the future and make everything obsolete. If you don't want to predict and use the best available now or if you got some business constraints on training and availability. Or if you are a religious fanatic.

    My personal direction. I'm using both Spring with Spring MVC and Spring with JSF as the MVC framework. I'm using hibernate for ORM and Spring JDBC package for simpler stuff. The company I work for company banned EJBs - AWESOME!

    Comment


    • #3
      Thank you very much for the awesome explanation. In my previous project, I also used hibernate and spring for ORM and dependency injection. I am new to spring MVC and JSF.

      Best regards,
      Sahra

      Comment


      • #4
        Also, since you asked specifically about portlets - check out the Spring Portlet MVC framework:

        http://opensource2.atlassian.com/con...ay/JSR168/Home

        This will be released as part of Spring 1.3, but has been very stable for the last several months and there are a lot of developers using it in production already.

        Comment


        • #5
          Just a quick note, a closely related topic is Spring WebFlow. It introduces the idea of a finite-state-machine. Struts and Spring MVC uses the conventional event driven model.

          It'll be added into the main Spring distribution in Spring 1.3.

          Comment

          Working...
          X