Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access spring beans through servlets

 
vini chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://tinyurl.com/2vws8u8
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use WebApplicationContextUtils class to get access to the ApplicationContext in the ServletContext. Check out the docs on this class.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic