I have tried getServlerContext().getRealPath()
in every way possible. Using it I can't get away from a NullPointerException
. And many other suggestions from Stack Overflow. None work successfully. My input text file that I'm trying to read from in one of my servlets is in my project's WEB-INFO folder. How do I access it locally using eclipse and Tomcat, and when I deploy to a hosting site? Any help with this would be greatly appreciated. Thanks in advance.
How to get relative path for input text file; getServletContext() returns null
150 views Asked by te7 At
1
I used getServletContext().getRealPath() in my initial called servlet and passed the path to the second servlet through a class variable in the second servlet. That worked. I guess since the second servlet is not actually initializing normally (I'm just calling it's doPost from the first servlet) the context for it is null. Thanks again for the help all!