How to integrate Spring to a Dynamic Web Project in Eclipse with JSP? - spring

I have looked everywhere and I have not found a site that can show how can I integrate Spring to my Web Dynamic JSP project built in Eclipse. All the references I have found, they are outdated or are using the new Spring Boot and Thymeleaf, which by default does not recognize JSP.
I am pretty sure, that this question may be sound silly for many Spring Programmer rock stars, but for me it is kind of BIG pain.
Can some one, please direct me to a web site, or book where I can integrate Spring? The real reason is because I want to integrate Spring Security.

After reading bunch of forums, books reviews and talking with some Spring veterans who migrated from standards JSP EE portal to the new Spring MVC. Here the Top 2 books I found indispensable for anyone who wants to port current JSP projects into Spring.
Spring MVC: Beginner's Guide (http://amzn.to/1PRoFS8)
2.- Mastering Spring MVC 4 (http://amzn.to/1Qc4UXG)

Related

Spring MVC vs Java EE

So I'm about to learn Spring MVC. But what I don't understand is why should I use Spring MVC if I can implement the MVC pattern using a single servlet conroller and JSPs? What advantages does Spring MVC provide over simple java MVC pattern?
Actually yes, you can do it. Question is if you should do it. Spring MVC gives you better organization of your code.
Pure MVC Frameworks like Spring MVC are obsolete today. When combined with templating engines like Thymeleaf, it lacks functionality and developers usually reinvent JSF. For single-page apps based on some popular JS frameworks that need REST backend, JAX-RS is way cleaner and better than Spring MVC REST.
So no, today you don't need Spring MVC and can stick with pure Java EE. For simple, toy-like applications where servlets are enough, you don't really need it but it may be better to use it. For anything serious, MVC is outdated and Spring has nothing to offer.
Edit 2017: Spring offers JAX-RS integration. However, it has several pitfalls, for example Spring won't automatically register classes annotated with #Path for you. Details can be found in Dzone Article
The best way to realize that it's better to play with these technologies for yourself, if you want to try spring MVC I recommend you start with spring boot because you can create projects with more agility without configuring xml files
Spring Boot
Some Features
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Provide opinionated 'starter' POMs to simplify your Maven configuration
Automatically configure Spring whenever possible
Provide production-ready features such as metrics, health checks and
externalized configuration
Absolutely no code generation and no requirement for XML configuration
One of the ideas applied in Spring (not invented by Spring) is
Do not reinvent a wheel.
Having a single controller is not a good idea I'd say - breaking separation of concerns principle.
You can learn more about MVC from Spring documentation.

Starting with Spring framework

I'm planning to start learning Spring but when I open any spring tutorial, I find many modules like Spring REST, spring MVC etc.
I'm really confused on how to start with spring, from which module to start, how are these modules related to each other, should I go through all the modules??
I tried searching many sites to answer my questions but couldn't find satisfactory ans, so thought of posting here. It would be great if somebody can guide me in this regard.
Spring is a java framework which provides solutions to several problems. So i guess it really depends on what you are planning to learn. The most important to learn first is understanding what Dependency Injection and inversion of control means. When you understand this you will understand why the rest of the frameworks are designed as it is. i suppose learn Spring IoC first since this is basically the core component of Spring Framework. Link: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/beans.html
After learning Spring IoC, you can go on learning each specific Spring frameworks which address specific problems. For example:
Are you interested in Web development? --> Spring MVC
Are you interested in storing data to database? --> Spring Data
Are you interested in developing web services / web apis --> Spring REST
http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/overview.html
Start with Spring Core Module, which is the heart of entire Spring.
Spring Core Module helps in Injecting Dependencies (java objects) into
the Application at Runtime.
Please refer below URL for more details:
http://www.springbyexample.org/examples/core-concepts.html
A good knowledge of design patterns is essential for learning any framework in Java.
These Youtube videos can give you a good understanding of basic Spring.
As explained in the previous answers, start learning with the Spring core. You need to have a sound knowledge of servlets, JSP, Hibernate (ORM's) to understand the advanced topics.

Can a simple JSp and servlet code be migrated to Spring framework?

I am a newbie in web development. I'm using servlets and JSP for web development.However, I've learnt lately that Spring Framework is apt for that which incorporate servlets, jsp etc. So, my question is that can I now run my program using Spring framework ? Like, I have 2 jsp codes, and 1 servlet class. So, how can I migrate the code in Spring Framework ? what additional things or codes do I need to maintain ?
Migrating an existing J2EE project is easy.
You will get rid of a lot of "boilerplate" code in the process. The easiest way to do it in my opinion will be to use SpringToolSuite.
Import your project in STS and then add "Maven" nature to it. In the pom configuration you can edit all the jars that you need and mention the spring framework. Once all this is setup it will be just a matter of minutes to change the code if it is small.
You can follow these video tutorials about maven and spring to learn about it.
JavaBrains
There are more tutorials by "New Circle training" on youtube for the same.
I would also recommend you to read Spring in action 3rd edition-Manning
This book is a must and the best way to learn spring framework. Hope this helps

Integration of AngularJS and Spring

I have to start a project in AngularJS, Spring and Hibernate. I know Hibernate and Spring but have no idea in AngularJS. Kindly suggest some good links of videos of project development in all AngularJS and Spring from scratch.
Are you looking for sample applications in Spring MVC and AngularJS?.Try following Applications which are done using above frameworks combinations.If you are beginner I hope this helps.
You may also interested in Integration of Spring Security with Spring MVC
and
angular-rest-springsecurity
That links helps to Explain good.

Should I learn Spring before Spring MVC?

I know java well, and have some experience in EclipseLink, Hibernate, JSF, Grails and some other stuff. but now I wanna learn Spring MVC for web apps and maybe for the sites. and should I learn Spring Framework before begin Spring MVC, or not?
In short, yes. Spring MVC borrows a lot of concepts like dependency injection from Spring, so you need to burn these concepts in before learning Spring MVC. For example, just create a simple Java project, create a few beans, understand the concepts of how a container / injection / wiring work, and then move on to implementing them in Spring MVC.
The most obvious benifit is you can integrate Spring with other web frameworks that you might already be familiar with. That way you get the best of both worlds, and don't have to learn Spring MVC until you have to.
This tutorial explains connecting to a database the spring way, and explains basic Spring concepts while at it. You could then follow it up with the Spring MVC tutorial.
Spring has an easy learning curve, (not to master it of course) so I would suggest learning them together on a small-scale test project.
I don't know if the question is pertinent for stackoverflow, but in any case I think learning Spring MVC is the best way to take a first step to learn Spring, in fact many Spring tutorials start with a Spring MVC application.

Resources