Search code examples
gwtrequestfactory

How do you access the Servlet Context (on the server) when using GWT Request Factory?


I need access to the ServletContext object that is usually available in servlets so that I can call methods like:

String fullPath = getServletContext().getRealPath("images/file.jpg");

I'm sure there is something built-in, I just need to figure out what it is.


Solution

  • All you need to do is:

    String fullPath = RequestFactoryServlet.getThreadLocalServletContext().getRealPath("images/file.jpg");