Results 1 to 2 of 2

Thread: getServlet() returning null with DelegatingActionProxy

  1. #1
    Join Date
    Feb 2007
    Posts
    6

    Default getServlet() returning null with DelegatingActionProxy

    Hi, I have been converting an old Struts 1x Application to integrate with Spring using the DelegatingActionProxy. When trying to get the servlet context from my struts action using the getServlet().getServletContext(), it is returning null for getServlet(). This does not happen when I do not use the DelegatingActionProxy.

    struts config:
    Code:
    <action name="aForm" path="/anAction" type="org.springframework.web.struts.DelegatingActionProxy" scope="request">
    	<forward name="success" path=".pages.aPage" />
    </action>
    application context (web):
    Code:
    <bean name="/anAction" class="com.xxx.xxx.web.action.AnAction">
        <property name="someService" ref="someService" />
    </bean>
    action class:
    Code:
    ...
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ...
    // Get Servlet is returning null
    getServlet()
    }
    ...

  2. #2
    Join Date
    Feb 2007
    Posts
    6

    Default

    Found another way of getting the servlet context:
    Code:
    request.getSession().getServletContext()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •