absolute path to the resources of the web application(GWT) on the container that hosts it
I have a GWT app. Am deploying it in tomcat. Within the servlet i want to write some code to create a temporary file. Right now am using file = new File("./../webapps"+this.getThreadLocalRequest().getContextPath()+"/svg/temp/"+svgName);
But this might not hold true for al开发者_开发知识库l web servers due to the 'webapps' hardcoding thing. Please help me out as of how can i solve this problem.
ps: 1) The servlet extends RemoteServiceServlet. 2) "/svg/temp/"+svgName is my app specific.
Prior to the Servlets 2.2 API, there was no standard location for temporary paths. The 2.2 API adds the javax.servlet.context.tmpdir attribute to the servlet context that defines where to write something:
File directory = (File)getServletContext().getAttribute("javax.servlet.context.tmpdir");
精彩评论