Announcement Announcement Module
Collapse
No announcement yet.
Any proxy servlet available in spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Any proxy servlet available in spring

    Hi

    I have created a servlet
    Code:
    class MyServlet extends HttpServlet{
    
    	public void doPost(HttpservletRequest req, HttpServletResponse res){
    	...
    	}
    }
    this servlet is my controller that handles all the request and is mapped in web.xml as
    Code:
    <servlet>
    	<servlet-name>myServlet</servlet-name>
    	<servlet-class>pkg.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    	<servlet-name>myServlet</servlet-name>
    	<url-pattern>/*</url-pattern>
    </servlet-mapping>
    I want this servlet to be created as a bean so that I can inject some dependent components and also inject this bean in some other beans. Please suggest me how this can be done?

    Is there any Proxy class for servlet, in Spring 3.0, similar to org.springframework.web.filter.DelegatingFilterPro xy for filter?

    Thanks
    Amit Khanna

  • #2
    Currently looking for an answer to that question myself. It's definitely not nice to obtain bean references through
    HTML Code:
    WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext())

    Comment


    • #3
      You can "wrap" your servlet with a ServletWrappingController, that way it basically sits behind a DispatcherServlet and you can use bean wiring and also apply HandlerInterceptors if you like.
      Last edited by Marten Deinum; Jun 8th, 2011, 02:22 AM. Reason: Removed ServletForwardingController it isn't applicable here.

      Comment

      Working...
      X