Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - RPC - get servlet absolute path to make dir

Tags:

file-io

rpc

gwt

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 ?

like image 421
user592704 Avatar asked Oct 10 '22 13:10

user592704


1 Answers

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

like image 158
user592704 Avatar answered Oct 18 '22 09:10

user592704