aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to access spring beans through servlets" Watch "How to access spring beans through servlets" New topic
Author

How to access spring beans through servlets

vini chauhan
Greenhorn

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,etc.how to integrate the project?
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

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.


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

Joined: Apr 18, 2009
Posts: 2234

http://tinyurl.com/2vws8u8


Save India From Corruption - Anna Hazare.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access spring beans through servlets
 
Similar Threads
Accessing EJB 2.1 Entity Beans via Spring services
Cannot get the reference of Spring bean
How to access Beans in any class ?
bean.xml ConnectException-Connection timed out: connect
Design query