Some initial configuration is needed before you can set about defining your bean definitions. This extra setup is not required if you just want scopes singleton and prototype.

In case you are using Servlet 2.4+ web container, then add the following ContextListener to the XML declarations in your web applications 'web.xml' file.

Java Code:

In case of older web container (before Servlet 2.4), use a (provided) javax.servlet.Filter implementation in web.xml File.



These snippets bind the HTTP request object to the Thread that is servicing that request. This makes beans that are request- and session-scoped available further in applications.