I have a web application running under Tomcat 5.0, and I need to write some output to a file. This app doesn't have its servlet context hardcoded in anywhere, so I can deploy it with any name and not worry about missing some random bit of code anywhere, and I often deploy it with different names so the customers can compare 2 versions side by side.
My problem is that I need to output to a log file within the application, and I'd like the logfile name to be the context name, so that I don't have to worry about 2 separate deployments inadvertently writing to the same file. I can get the context path from the first request that comes in, but until that point, I don't seem to be able to retrieve it from either the ServletContext or the ServletConfig... Am I missing something? I'm running in Tomcat, so I can hack it using some Tomcat-specific code, but I'd rather leave it as portable as possible. Anyone have any ideas? Cheers in advance -- Stuart Wood