Class TempFileHolder

  • All Implemented Interfaces:
    EventListener, javax.servlet.http.HttpSessionBindingListener

    public class TempFileHolder
    extends Object
    implements javax.servlet.http.HttpSessionBindingListener
    Attaches an uploaded file to the session with a listener, so the file will be deleted if
    • The session times out.
    • The session is invalidated.
    • The server is shut down.
    • Another file is attached to the session with the same attribute name.
    To see that the file isn't deleted, remove it from the session with a call to remove.
    • Method Detail

      • attach

        public static void attach​(javax.servlet.http.HttpSession session,
                                  String attributeName,
                                  FileInfo fileInfo)
        Create a holding the given FileInfo, and attach it to the session with the given attribute name. If an attribute with this name already exists, it is replaced.
      • remove

        public static FileInfo remove​(javax.servlet.http.HttpSession session,
                                      String attributeName)
        Get the which is stored as an attribute on this session, extract the FileInfo from it, and remove it from the session. If there is no such attribute, of if it is not a , return null.
      • valueBound

        public void valueBound​(javax.servlet.http.HttpSessionBindingEvent event)
        When attached to the session, do nothing.
        Specified by:
        valueBound in interface javax.servlet.http.HttpSessionBindingListener
      • valueUnbound

        public void valueUnbound​(javax.servlet.http.HttpSessionBindingEvent event)
        When removed from the session, if the fileInfo is not empty, delete the file. If you had wanted this file, you should have called remove.
        Specified by:
        valueUnbound in interface javax.servlet.http.HttpSessionBindingListener