User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 391,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,739 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 954 | Replies: 0 | Solved
Reply
Join Date: Aug 2007
Posts: 1
Reputation: blaykm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
blaykm blaykm is offline Offline
Newbie Poster

Deleting Uploaded files

  #1  
Aug 22nd, 2007
Hi I have a web Application which uses servlets. As soon as any user Logs i create a folder for the user and the files uploaded by the user are stored in that folder. Now when the users Logs out of the Application I am supposed to delete the folder and all its content.
I used File API to achieve this But I get a
[Inline]
java.security.AccessControlException: access denied (java.io.FilePermission C:\Sun\ApplicationServer\nodeagents\SPINE-POD03\AppServer1\applications\j2ee-apps\harness\simulator_war\temp\guest1\input\ACFHasResourcePermissionsRequest.xml delete)

[/inline]

I use SJAS 8.1 as my application server the code is as follows

  protected void doGet(
            HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
       HttpSession session = request.getSession();
       File userDir = new File((String)session.getAttribute(WEB_USER_FOLDER));
       recursivelyDeleteDirectory(userDir);
        session.invalidate();
        System.out.println("Session Destroyed ");
        response.sendRedirect(WEB_LOGIN_URL);
    }

   private  void recursivelyDeleteDirectory(File dir) throws IOException {
      if ((dir == null) || !dir.isDirectory()) throw new IllegalArgumentException(dir + " not a directory");
      final File[] files = dir.listFiles();
      final int size = files.length;
        System.out.println("Files size = " + size);
      for (int i = 0; i < size; i++) {
        if(files[i].isDirectory()) {
          recursivelyDeleteDirectory(files[i]);
        } else files[i].delete();
      }
      dir.delete();
    }

Please can any one help me out with this issue..

Thanks in Advance
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 9:56 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC