What are the roles and responsibility of servlet container and spring container? Please someone clarify my doubts.
Servlet: a server side java class to produce the html content. Spring: A framework to develop Big Enterprise Application which include your servlet as well.
A Servlet Container or Web Container (like Tomcat) is an implementation of various Java EE specifications like Java Servlet, JSP, etc. Put in a simple way, it is an environment where Java web applications can live. A web server + Java support.
In Layman terms : A web Server means: Handling HTTP requests (usually from browsers). A Servlet Container (e.g. Tomcat) means: It can handle servlets & JSP. An Application Server (e.g. GlassFish) means: *It can manage Java EE applications (usually both servlet/JSP and EJBs).
An IoC container is a common characteristic of frameworks that implement IoC. In the Spring framework, the interface ApplicationContext represents the IoC container. The Spring container is responsible for instantiating, configuring and assembling objects known as beans, as well as managing their life cycles.
They are very different concepts also if their names are similar.
A Servlet Container or Web Container (like Tomcat) is an implementation of various Java EE specifications like Java Servlet, JSP, etc. Put in a simple way, it is an environment where Java web applications can live. A web server + Java support.
A Spring Container on the other hand, is the core and the engine of the Spring Framework. It is an IoC Container that handles Spring applications lifecycle creating new beans and injecting dependencies.
Because a Spring application can be a web application, a Spring Container can "live" inside a Web Container.
For further information:
about Servlet Container: http://en.wikipedia.org/wiki/Web_container
about Spring Container: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With