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 friends , I am devloping a application which requires a servlet to read text file.I have written the code and it si not showing any error .But the problem when i start my Tomcat server then it shows the text file not found error and automaticaaly shutsdown.I have stored the text file in \webapps\ROOT\WEB-INF\classes directory.plz help me Thanking all in advance Ullas
Because a servlet app can be deployed from either a file system structure or a war file, there is no guarantee that your file will exist on the systems hard drive as a 'file'.
The ServletContext.getResource and ServletContext.getResourceAsStream methods are provided for just this reason. If you use one of these methods, you will be able to refer to your file, relative to the context root of the app.