>Hi guys, >is there anyway for a servlet to know the directory they are in ? >eg. C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\46xx\WEB-INF\classes\ >or at least up to C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\46xx\ ?
You could use: getServletContext().getRealPath("/WEB-INF/hello.txt"); ...to get the real path on disc of the webapplication or a file within it. Finding the servlet class file itself can not be done automatically, since the servlet object lives in a virtual space with no idea of where it's definition resides. But you can map the file manually, if needed. You can also try to fiddle with Class.getResource() and Class.getResourceAsStream() in combination with the method above to see if you can come up with some solution. Regards Erik Beijnoff ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html