GWT - RPC - Get the absolute servlet path to mkdir

advertisements

I tried to read a file with my "RemoteServiceServlet" but the thing is

  • I want to create a dir which path is related to servlet like

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