This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi there, I would like to deposit a dynamic generated page for subsequent calls. But I don't know how to set a path for it. As you know, that the general path for web container as follow: ..\tomcat5512\webapps\ROOT\html
If my servlet generates a.html, b.html under above directory, how do I set the path relative to that directory?
I don't want to has java code to pick up by environment variable. and my servlet package is a.b.c because I want to turn this servlet to bean in phrase 2. Thank you very much.
John, One thing to keep in mind. Java webapps aren't always deployed as a file system directory. When they are, you can get the system path to any resource within your application using java.lang.String)" target="_blank" rel="nofollow">ServletContext.getRealPath
If your webapp is deployed as a packed war file this method will return null.
A more robust way of doing this is to use context init params or servlet init params that are configured in web.xml.