2
votes

This text is from the book called Core Java Server Faces:

It is a historical accident that there are two separate mechanisms, CDI beans and JSF managed beans, for beans that can be used in JSF pages. We suggest that you use CDI beans unless your application must work on a plain servlet runner such as Tomcat. The source code for the book comes in two versions, one with CDI beans (for Java EE 6 application servers) and one with JSF managed beans (for servlet runners without CDI support).

My question is:

If I use the Spring Framework, and a Tomcat Server, will I need to use one of the beans mentioned above, or does Spring Framework come with its own bean implementations?

As far as I know, Spring Framework supports Dependency Injection. Does it support it if I run the application on Tomcat? Does it mean that I will be using neither the CDI beans nor the JSF Managed means mentioned in this book?

Thank you.

1

1 Answers

2
votes

talking about container is more correct than bean implementation. Yes Spring comes with its own container. In fact you can see spring frameworks as a kind of alternative to the full Java EE stack.

Using Spring DI and CDI together has about no interest but you still can use JSF with spring on tomcat although if i would advise you to switch to a Java EE 6 web profile server instead of spring in this case.

Spring comes with is own view framework implementation named spring mvc.

All of this can run perfectly on any servlet container (jetty tomcat etc...) on condition that you provide associated dependencies ofc.