1 Reply Latest reply on Mar 26, 2004 3:51 PM by Brian Stansberry

    no access to ServletContext

    null null Newbie

      This is a simple answer I'm sure -
      1) implemented a javax.servlet.http.HttpServlet (JSE 1.4.2) with Tomcat4.1/Jboss3.2.3 within a .war directory
      2) Trying to access the servlet context in the doget(). getServletConfig returns null; getServletContext throws a null pointer
      3) There are context and config objects existing during the init() execution:
      org.apache.cataline.core.StandardWrapperFacade
      org.apache.cataline.core.ApplicationContextFacade
      4) I have set the <context-root>/</context-root> in jboss-web.xml

      Question:

      What do I need to set in what .xml config file to get my webapplication (so far a single jsp) to be able to initialize the context

      Thanks,

      Linda Rae
      lsrae@sbcglobal.net

        • 1. Re: no access to ServletContext
          Brian Stansberry Newbie

          Which init() method are you overriding?

          init()
          or init(ServletConfig config)

          If it's the latter, be sure the first line in the method body is

          super.init(config);

          or else the ServletConfig object will not be stored by the servlet and you will get the errors you report.

          Better yet, override the no-arguments init(), as the purpose of the no-arg version is to avoid having to call super.init(config).

          Best,
          Brian