session bean destructor
843841Jul 22 2005 — edited Jul 22 2005An application that I am working on has a bean that retains information about files uploaded by the user. The files are temporary, and need to be deleted at the end of the user's session-- hence the bean.
<jsp:useBean id="fileupload" class="changehoursrequest.FileUpload" scope="session" />
I was hoping that all that I would have to do is define a destructor in the bean (protected void finalize()) that deletes the temporary files. The destructor does what it's supposed to do, but doesn't seem to be called when the session ends. Is there a listener that I need to use? Am I doing something else wrong? Any suggestions?
Here's the skelaton of the bean..
public class FileUpload implements Enumeration
{
public FileUpload(HttpServletRequest request) { }
public FileUpload() {}
public MultipartRequest getRequest() {}
public void setRequest(HttpServletRequest request) { }
public String getFileName() {}
public String getFileType() {}
public String getFileSystemName() {}
public String getFileContents() {}
public boolean hasMoreElements() {}
public Object nextElement() {}
// destroy temporary files
protected void finalize() {}
}
thanks,
Bryan