-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Aladdin,
aladdin wrote: > I have the following two lines of code in a context listener: > > ServletContext sc= e.getServletContext(); // e is a ServletContextEvent > log.write("AppInitializer::ContextInitializer: context name='" + > sc.getServletContextName() + "'"); > log.write("AppInitializer::ContextInitializer: context path='" + > sc.getContextPath() + "'"); > > When I try to compile this, I get: > ./src/utils/AppInitializer.java:33: cannot find symbol > symbol : method getContextPath() > location: interface javax.servlet.ServletContext > log.write("AppInitializer::ContextInitializer: context path='" + > sc.getContextPath() + "'"); > > Why is it not finding the function (and only the function) > ServletContext.getContextPath()? It's the first time I've used this > function, but it is typed (I think; maybe I'm going crazy- too much > programming, ya' know) exactly as it appears in the Sun J2EE documentation. Unless you can use a Servlet 2.5-spec container, I don't think you can do what you want to do. It looks like you want the webapp's context path for logging (i.e. the "/myWebapp"), but there's no access to it before the 2.5-spec (though I'm not sure why... it seems like a basic piece of information that should not require a request to fetch). Since it's just for logging, I'm sure that ServletContext.getServletContextName will meet your needs... you'll just have to set a <display-name> in your deployment descriptor (web.xml). - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGtz9W9CaO5/Lv0PARAkxWAJ9DRdq76lfr4gYfIYAztbpBYnLsogCglpwW 0Xgz7oZskGKBNlSy+rVFO7Y= =zzkx -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]