Results 1 to 3 of 3

Thread: Any proxy servlet available in spring

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    26

    Default 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. #2

    Default

    Currently looking for an answer to that question myself. It's definitely not nice to obtain bean references through
    HTML Code:
    WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext())
    Marcel Stör, http://www.frightanic.com
    Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    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 at 02:22 AM. Reason: Removed ServletForwardingController it isn't applicable here.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

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