I tried to read a file with my "RemoteServiceServlet" but the thing is
absolute_servlet_path/myPackage/
But the problem is...
code like
ServletContext servletContext = this.getServletContext();
String pathContext = servletContext.getRealPath("");
... gives not "C:/..." but "/" only so the code cannot be used with java.io.File object.
So my question is how can I use java.io.File with RemoteServiceServlet ?
OK... I had to keep digging...
Still I was looking for a way of servlet relative path but an absolute one; and now again I tried to use the context but this time I modified my code in this direction...
ServletContext servletContext = this.getServletContext();
String pathContext = servletContext.getRealPath("/WEB-INF/");
... and it worked for my Tomcat :)
I hope it saves one's day
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With