What is the most effective way of getting a servlet's full/absolute path? There is a getRealPath() method in the javax.servlet.ServletConfig interface but i'm not clear about how to implement this interface. Especially since an interface is abstract by definition and can't be instantiated.
You don't implement the servlet config interface. An object that already implements that interface is available to you within any servlet via getServletConfig(). That said, what path are you really trying to discover? getRealPath() may not be the correct mechanism. hth, bear [ June 30, 2003: Message edited by: Bear Bibeault ]
Not sure if this is what you want but: this.getClass().getName() returns the fully qualified class name. If you want the name of a different servlet than the one currently being ran you can do this: MyServlet.class.getName() as long as the appropriate import statement is made to include MyServlet.
No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Thanks for your help. As i'm loading a properties file ( db name, db address, etc ) in an init() of my parent class. Getting the servlet to automatically discover the full path name to this file is useful as the servlet context changes between my live setup and development setup. So i've used the getServletContext() method to get a ServletContext object and i was able to then get the full windows path of a folder within the servlet context: ServletContext servletContext = getServletContext(); String strAbsolutePath = servletContext.getRealPath("properties");