What the difference between struts2 and spring MVC - spring

I am learning Java EE and wanna build up a complete management system for a restaurant. Now I am confused what presentation layer should I use for my RMS because I heard that the struts 2 is one of the best UI layer but, the thing is, if I am using spring for my business logic layer then I can use the spring MVC can't I? By the way, I am really interested to build a complete application which is follow the multi-tier architecture.

Yes, of course you can use Spring MVC.
You can use Struts 2 if you'd like as well, because Spring integrates with it nicely.
But I don't see any reason why you'd want to do that. The person who told you that Struts 2 is
one of the best UI layer [sic]
is misguided. If you compare it to Spring MVC, you'll see that the two are based on similar ideas, but Spring improves on Struts. JSF has superceded Struts as the default Java EE web view technology, so it's not even considered "best" by the Java EE standard.
Stick with Spring. You won't be sorry.

I will not blame struts 2, indeed it's a great product, I work with it every day. But in my experience spring MVC is a lot simpler and clearer. This doesn't mean you don't get as much features.
Try both, and you'll see what I mean.
Tell us which one you choose!

Related

Is Migration from Struts to Spring wholesale change?

I have a Struts 1 application and I am exploring different options for upgrading the system. One option is Spring MVC or Spring Boot. If I were to choose either framework to migrate the application to, can I do so transitionally (piece by piece) or would it be a complete wholesale change or complete rewrite. Don't know if I'm making myself understood.
Spring 3.0, had explicit support for integrating struts 1. This was two major versions of spring and 9 years ago. There is documentation here:
https://docs.spring.io/spring/docs/3.0.5.RELEASE/reference/web-integration.html#struts
Integration consisted in either using the ContextLoaderPlugin to allow spring to manage all your action classes, or to make your action classes aware of the spring context. A fair amount of struts specific code was available to do things like map struts action handlers to action beans in the spring context.
You could probably reproduce a lot of this in spring 5, but you'd have to do a lot of heavy lifting on your own. There are probably very few struts/spring 5 users out there to help you.
You could also go with spring 3.0 to make the integration easier, allowing you to do the migration in steps, but then you are in a different bad place. You have an old version of spring that fewer people use, and none of the goodness that 9 years of releases have wrought.
If you want to migrate your struts 1 app to spring, you are probably going to have to do it all at once. Redo your action classes as springmvc controllers and then rewrite your views (templates). spring mvc is pretty view agnostic and there are many good choices.
Good luck and have fun!

Spring MVC view technology: what to choose?

I want to create web-site with Spring back-end, but I can't choose what view technology to use: JSP, Velocity, or I should try to integrate JSF with my app. Which of this technologies is the most popular?
Looks like that JSP is a quite deprecated technology, but I hasn't found a proof of this thesis yet. Should I learn JSP, or try some another framework?
I´d use JSP+JSTL+Tiles, but mainly because everybody knows them. I could consider to use Freemarker or Velocity (Specially the first). However, I think Spring MVC and JSF are technologies that overlap, and using them together could be useless and dangerous.
I recommend you to take a look at this: http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/view.html
And also at this: http://ihatejsf.com/

Migrate struts action to spring action

I am looking for a good tutorial on migrating from struts to spring. I have multiple struts actions that I would like to refactor into spring components.
Here's one (assuming you're talking about Struts 1, although you don't specify).
Not sure how helpful it will be; depending on how clean the original Struts code was it could be relatively straight-forward, or brutal.
In my experience the bulk of the work lies in the JSPs, not the actions themselves, particularly if the S1 code made extensive use of the Struts tags. The actions themselves are easier to deal with because of strong IDE support.

Migrating from Struts2 to Spring MVC

Scenario: A fairly mature project uses Struts2 and Spring and Hibernate. I say mature because it has been going on a for a while and there are many struts actions written already.
Suppose we wanted to remove Struts2 from the project and instead depend entirely on Spring MVC without rewriting the entire project.
Is this something that should even be considered?
Are there any migration guides out there?
Has anyone done this before and would like to warn me against it?
If it ain't broke, don't fix it. You have very likely better things to do than a migration that won't add any value to the product (and will certainly introduce some bugs). If I were the business, I would never buy such a migration (with close to zero benefits).
I have to ask: What advantages do you see with Spring MVC that aren't being fulfilled by Struts 2?
If there's not at least a handful of "smoking hot" features, or the amount of time saved is more than enough to overcome the time taken for the migration in the first place then it's probably best to stick with what you have.
You can do it slowly. Struts is a MVC framework. The rest of your application (business and data tiers) are classes which can be invoked by action classes. Struts is a plugin based architecture and it is easy for you to define a plugin in struts configuration file.
Take a look at this link. This may help.
With Struts2 security vulnerabilities being exposed and reported often, this task takes on more importance.

What are the advantages/disadvantages of Seam over Spring?

What are the advantages/disadvantages of Seam over Spring? Why would I use Seam in lieu of Spring?
Is there anything that can be done in Seam that can't be done in Spring? Anything in Spring that can't be done in Seam?
What about stateful/stateless architecture? I am a Spring user, so I am biased, naturally.
Why Spring?
Cleaner code
Streamlined application configuration
Nice integration with popular open source products
First class AOP support
Enterprise-scale security: Acegi
Highly flexible MVC
Abstracted data access (JDBC is OK)
Enterprise Java without EJB
Testing is easy
Why Seam?
Merge Java EE 5 standards (EJB 3.0, JPA, JSF, Annotation) seamlessly
Stateful by design
Bijection
Integrated Ajax (ICEfaces and Ajax4JSF)
Business process integration (jBPM)
Business rules integration (Drools)
Workspace management
Deliver complete stack (from JBoss & RedHat)
Seam Text and EL enhancements
Probably will be a standard (JSR-299: Web Beans)
From Framework Deathmatch: Spring vs Seam. Thomas Wiradikusuma (Spring). Joshua Jackson (Seam). Java User Group Indonesia. JaMU 07.03. March 17, 2007 power point presentation here
although seam does have many advantages over spring, there is a magic word that really is worth paying attention to and this is PERFORMANCE!!! if you are not worried about performance issues I would go with seam. From the other hand if you want your application to be as fast as possible and your hardware is limited I would use spring. I am not saying that you can not develop fast applications with seam, but in order to do this you really need to know what you are doing. I have used both of them (i am not a guru in any of them) and what I found out is that although spring needs more effort to build what you want, at the end the result is more flexible and is performing better. I do not think that there is something that can be done in one framework that it can not be done in the other, saying that, remember that I am not an expert to any of those.
Seam will give you a pretty, ah, seamless, integration between the components that make up the seam stack. All very nice as long you keep within that stack, and within the seam model and foing things. It all starts to look a little less convincing as soon as you start doing something unusual, though.
If it's not too much of a generalisation, Seam is very "microsofty" in that regard. This isn't a bad thing, it's just a stylistic thing. Spring is more open-ended and takes more effort to get going, but it's ultimately more flexible, and a lot more open.
You can use Spring and Seam together - Spring for backend components, Seam for enhancement of web layer (JSF/GWT/Wicket) and other stuff. Seam offers a lot of Spring functionality (i.e. IoC container, transaction managment) - in your project you can decide - witch implementation to use.
More details on integrating Seam with Spring - "Seam in Action - free bonus chapter"
Let's compare the two.
What is common?
Both are open source, follow MVC architecture and has a servlet based front controller.
Advantages of Spring MVC
Extension of Struts.
View can be developed using JSP and HTML. You can also plugin other's like PHP or velocity.
Has large number of controllers predefined.
Integrated out of the box with Spring framework.
Advantages of Seam
Extension of JSF
View can be developed using JSF component library. There are large number of vendors to choose from.
Integrates JPA entities with Web layer
Annotation based validation
Integrates with EJB 3.0
Out the box jBPM support which provides process flow definitions.
Integrates with Drools where you can define web layer business rules.
Good community support.
Conclusion
Since Seam is built on JSF, it has large number of UI Component libraries to pick from. It reuses Java EE stack better. It has lot of interesting modules integrated beforehand.
Spring MVC is built on top of Struts and Spring, so it will reuse Spring framework stack far better than others. But the view is built using JSP, so we have to rely on JSP tag library vendors to build rich components.
Seam framework would be a better choice as Spring framework is anyway extensible enough to be leveraged by Seam.

Resources