Results 1 to 2 of 2

Thread: servlets, tomcat, and app contexts

  1. #1
    Join Date
    Oct 2005
    Posts
    1

    Default servlets, tomcat, and app contexts

    I have a servlet I configure via my applicationContext.xml. On web app startup, my servlet is instantiated and configured. But then, because I also have the servlet specified in the web.xml, Tomcat initializes its own without going through Spring.

    When I send a request to the servlet, the one Tomcat created is called, not the one Spring created.

    I had this issue with filters, and the DelegatingFilterProxy solved the problem. I was looking for something like that; the classes ServletForwardingController and ServletWrappingController looked promising, but I couldn't get them to work.

    I'm guessing I can't specify the servlet in the web.xml. If I do, Tomcat will try to instantiate it for me.

    My questions are:
    1. Can you have Spring configure your servlets?
    2. If so, what do you specifiy in the web.xml?
    3. Do you need to use one of ServletForwardingController or ServletWrappingController? or is there a different class?

    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You may subclass org.springframework.web.servlet.HttpServletBean. It treats config parameters as bean properties. If you need full featured resources injection, you may override initServletBean and implement dependency lookup.
    Hope this helps.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Posting Permissions

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