• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Temporary Working Directories (ServletContext)

 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Temporary Working Directories (ServletContext)
Servlet specs says that a Temporary Working dor must be there corresponding to each servletContext and
made available thru "javax.servlet.context.tempdir" attribute, the object is a File type.
What is the use of this directory?? is it to store the context?
I tried this example..
***************************************************
public void doGet(HttpServletRequest pRequest,
HttpServletResponse pResponse) {
try {
ServletContext lSC = getServletConfig().getServletContext();
lSC.setAttribute("Andy", "testing data");
File lf = (File)lSC.getAttribute("javax.servlet.context.tempdir");
PrintWriter lOut = pResponse.getWriter();
lOut.println(lf.getName());
lOut.println(lf.getAbsoluteFile());
} catch (Exception lE) {
lE.printStackTrace();
}
}
***************************************************
I got the output as:-
******************************
test
D:\Program Files\Apache Tomcat 4.0\work\localhost\test
*****************************
test is the name of the context....
But when i checked the contents of this directory... i found it to be EMPTY
So wat is stored in this directory and when??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic