views:

56

answers:

1

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 all 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.

A: 

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");
mjustin