Announcement Announcement Module
Collapse
No announcement yet.
Getting the WebapplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting the WebapplicationContext

    Hi,

    I have a web application ...(struts+spring dao)

    In this action class i extend dispatchaction support and get the web application context from where i get the DAO bean..(ctx.getBean(""))

    Now i need to add a new webservice class(not an action class)....During the intermediate logic,i have to invoke the DAO class...But in the new webservice class ,i dont have the webapplication context..and so am not sure how to get the bean...

    Is there any way i can get the bean from the context...

  • #2
    You can use one of the following method based on servlet or portlet

    org.springframework.web.context.support.WebApplica tionContextUtils#getWebApplicationContext(ServletC ontext sc)

    org.springframework.web.portlet.context.PortletApp licationContextUtils#getWebApplicationContext(java x.portlet.PortletContext pc)

    Comment


    • #3
      Thanks Kapil,

      But the class where i would need the context doesnt extend any of these claases onor does it have any means of getting Servlet context directy..

      So i figured it out by implementing ApplicationContextAware

      and specified my class as a bean..

      And i had the context populated.
      I believe this is a correct approach

      Regards

      Comment

      Working...
      X