File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes How to access spring beans through servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to access spring beans through servlets" Watch "How to access spring beans through servlets" New topic

How to access spring beans through servlets

vini chauhan

Joined: Dec 07, 2010
Posts: 5

In my project the servlet need to access beans through spring framework which has its own xml like built xml,app-context xml, to integrate the project?
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Vini,
I don't think you have to do anything special to integrate. During your server start-up when application class files are loaded, one of the classes say Spring Factory class's static block or method would load spring configuration xml. So, you can access from your Servlet Spring beans like any other Java Bean classes.

(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Save India From Corruption - Anna Hazare.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

use WebApplicationContextUtils class to get access to the ApplicationContext in the ServletContext. Check out the docs on this class.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: How to access spring beans through servlets
jQuery in Action, 3rd edition