The easiest way to get this behavior is to override init(ServletConfig config) in your servlet and forget to call super.init(config) as instructed in the Javadoc. You can either call super.init(config), or override init() instead, which is called from super.init(config).
Cheers, Larry > -----Original Message----- > From: Stan [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 14, 2002 9:39 AM > To: [EMAIL PROTECTED] > Subject: getServletContext() returning null... > > > I have a servlet in which I am trying to pass control to a JSP page to > conform with the JSP Model 2 scenario. I am using Tomcat 3.3 > under Win98 and > have setup a webapp (jforum) with the config files as listed > below. For some > reason when I try to obtain the ServletContext for the > servlet in order to > dispatch the request over to the JSP I get null back from the > getServletContext() call. Is there anything in the > configuration I have > supplied which would stop this context being created > appropriately? I would > presume that a servlet would necessarily be part of a > ServletContext, and > therefore it couldn't return null, but perhaps I am wrong. > > Any help much appreciated, as this is driving me up the wall! > > Stan > > > > tomcat/conf/app-jforum.xml: > --------------------------- > <?xml version="1.0" encoding="ISO-8859-1"?> > <webapps> > <Context path="/jforum" > docBase="webapps/jforum" > debug="9" /> > </webapps> > > > tomcat/webapps/jforum/WEB-INF/web.xml: > -------------------------------------- > <?xml version="1.0" encoding="ISO-8859-1"?> > > <!DOCTYPE web-app > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" > "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> > > <web-app> > <display-name>JForum</display-name> > <description> > A web-based forum system, allowing threaded topics. > </description> > > <servlet> > <servlet-name> > jforum > </servlet-name> > <servlet-class> > slink.apps.jforum.ControlServlet > </servlet-class> > <init-param> > <param-name>maxAge</param-name> > <param-value>120</param-value> > </init-param> > <init-param> > <param-name>maxObj</param-name> > <param-value>500</param-value> > </init-param> > <init-param> > <param-name>debug</param-name> > <param-value>true</param-value> > </init-param> > </servlet> > > </web-app> > > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
