How can I remove a file on server w/ my JSP app running on Tomcat 7 ?

First of all, I'm posting here because I found it the closest to java web development in the forums listing.
How can I remove a file on the server side with my JSP app running on Tomcat 7 ? I did it in a JSE app by changing permissions, but how can I do it for a simple JSP app ?
My code is
public static void excluirArquivos(String nomeArquivoExcluido) {
          File arquivoExcluido = new File (nomeArquivoExcluido);
          arquivoExcluido.setWritable(true, true);
          SecurityManager sm = new SecurityManager();
          try {
               sm.checkDelete(arquivoExcluido.getAbsolutePath());
               System.gc();
               if (arquivoExcluido.delete()) System.out.println("File '" + nomeArquivoExcluido + "' successfully removed.");
               else System.out.println("File '" + nomeArquivoExcluido + "' wasn't removed somehow.");
          } catch (SecurityException se) {
               System.out.println("File '" + nomeArquivoExcluido + "' can't be excluded. There is no permissions.");
     }And it always falls on the catch statement.

899238 wrote:
How can I remove a file on the server side with my JSP app running on Tomcat 7 ? I did it in a JSE app by changing permissions, but how can I do it for a simple JSP app ?1. make sure that the JVM has the (filesystem) rights to be able to remove said file
2. make sure the file is in fact not locked (for example, opened by another process)
3. use File.delete()
There is no guarantee that you can delete a file, you can only make an attempt. There can be any number of reasons, most if not all of them not related to code, that the deletion of a file does not work.

Similar Messages

  • How can i remove secure files from the trash? I tried click away the secure notification in info, but still i cann't remove them. Is there a buttoncombination to use?

    How can i remove secure files from the trash? I tried click away the secure notification in info, but still i cann't remove them. Is there a buttoncombination to use?

    If you are unable to empty the trash, try holding the Option key while selecting Empty Trash.
    Otherwise, some steps in the following link may help you.
    http://support.apple.com/kb/ht1526

  • HT1391 How does one delete apps or files from iCloud Permanently so I may re-download without retrieving existing cloud file?for example the U2 Marketing fast , an Album I have no interest in...is now in my Cloud.. How can I remove this File from iPhone &

    How does one delete apps or files from iCloud Permanently so I may re-download without retrieving existing cloud file?for example the U2 Marketing fast , an Album I have no interest in...is now in my Cloud.. How can I remove this File from iPhone & cloud

    Hey there Matt.dvs1,
    Although there is not a way to remove past purchases from your iTunes account completely, you can hide them so that you don't have to see them if you don't want to. This article will help you do that:
    iTunes Store: Hiding and unhiding purchases - Apple Support
    Hide your purchases
    Open iTunes on your Mac or PC.
    From the Store menu, choose Store > Sign In, and then enter your Apple ID and password.
    Go to the iTunes Store.
    Click Purchased from the Quick Links section on the right side of the iTunes Store.
    Choose a content type by clicking Music, Movies, TV Shows, Apps, or Books from the top of the window.
    A list of your purchased items for the content type you are viewing will appear. Mouse over the item you want to hide until an X appears its top-left corner.
    A confirmation dialog will appear once you click the X.
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • How can I remove a flag using a rule in Mail.app?

    I'm using Mail Act-On to flag messages that are important. I also have got a smart mailbox that displays only those messages that are flagged, this is my "To Do" mailbox.
    Once I've read and answered the message I want to remove the flag, preferrably via a rule using Mail Act-On as well. However in the rules dialog in the Mail.app preferences there's only the option to set a flag, not to remove one.
    Can anyone help: how can I remove a flag using a rule?? Maybe via Applescript as the last resort?
    Thanks for any advice Jan

    Hi Jan
    I haven't gotten around to put unread and unflag into Mail-ActOn but MailTags has the functionality. MailTags also allows you to mark a message unread via act-On rule.
    It is interesting to note that apple doesn't include unflag and unread as the rules were originally intended to apply only to new messages (of which none should be read or flagged) with that logic, there would be no need for unread, unflagg.
    @David: The reason to do it via Act-On rule would be to set up a sequence of events, one of which is to unflag, others may be to set keywords, move messages, set colors etc.
    Scott

  • How can I remove .nrw files from my NOKIA Asha 200...

    When I am connecting my NOKIA Asha 200 with my PC by data cable, I am watching almost 50 nos. *.nrw files inside the Image folder. I tried to delete all those file, but I was unable. Is there any one, who can tell me how to remove those files from my phone memory?
    Thanks & regards,
    Sudip Sinha.
    Calcutta.
    India.

    Back-up your data and then Factory Reset your phone ...(Menu-->Settings-->Restore Factory settings-->Settings only.. followed by 12345 which is default security code, unless set by you) .. When the phone reboots, check whether these .nrw files are now converted to .jpg .. If so, you should be able to delete them now ...

  • How can I remove audio files from ipod totally not just playlist

    I understand how to remove from playlists, how can a file be totally and permanently removed to free up memory?

    If you sync by playlists, then remove the song from the playlist in itunes, then sync. The song will be removed from the ipod.
    However, if you have genres, artists, etc checked, then you would have to remove that genre, artist,etc from the song info.
    If you sync by checked song, then uncheck the song and sync.

  • How can I remove the first exchange server 2010 without any problems in DC

    Hi,
    our actually exchange is running on windows server 2008R2 with exchange 2010. I already install & configured a second Exchange 2010 server in the same domain. I also moved every mailbox to the new server. Now I have to deactivate the first server and
    I don't know, if I have to do something or can I deactivate the "old" server without any issues.
    If I can deactivate it, how can I do this? Is it enough to uninstall exchange 2010 on the server and after that I uninstall the windows server? Did I have to change something before?
    Thanks,
    Mesut Uygun
    btw. sorry for my bad english

    Hi MesutU,
    When you remove first Exchange Server 2010 in your organization, please confirm finish following steps:
    1. Move all mailboxes (including discovery and arbitration) to another server
    2. Move all Public Folder replicas
    3. Move OAB generation server
    4. Update SMTP flow from internet
    5. Update OWA/IMAP/POP/OA access from internet.
    6. Update any routing group connectors if 2003 is present
    7. Turn the old server offline for some days to check whether the new server works well.
    More information about How to Remove the First Exchange 2007 Server in a Coexistence Scenario (even if the version of Exchange server is different), for your conference:
    http://technet.microsoft.com/en-us/library/bb310767(v=exchg.80).aspx
    Best Regards,
    Allen Wang

  • How can I remove all files or bad files on my Ipod 60gb

    Hi all!
    For unknown reasons , all my music library 7.5 Gb have been re-loaded on my Ipod 60Gb. It take a long time, but it doesn't erase the previous datas on my Ipod.
    I have around 7.5 Gb of my hard used with wrong datas !
    how can I erase and remove these wrong files ?
    Thanks for answers
    regards
    Chat_noir

    Restore it.
    See: How to restore the iPod to factory settings.

  • How can I remove a file that is no longer associated with a page?

    I have a hurdle that is preventing me from completing a task.
    I am trying to build a spry asset--specifically a vertical menu. When I initially built the page, I built the menu. However, the look was rejected and I was asked to re-create it. I went back, removed all references to the spry asset, and stripped the menu from the page. But when I open the page which I want to build the menu on again, it is still showing that a .css and .js file are associated, event though they aren't. And when I try to rebuild the asset, it won't  add the proper .css and .js file because it thinks the files are already created.See the screenshot below to view what I'm talking about.
    If anyone has an idea of how to tell Dreamweaver that those two files are no longer associated with the page, I would appreciate some help. THis is the last major hurdle before I can complete a project.
    Thanks,
    Ken

    Hi
    Providing you have removed all references to the js/css files, (have you removed the code at the bottom of the page?), use the spry updater to insert your new js/css.
    You can get the spry updater extension form the downloads box here - http://labs.adobe.com/technologies/spry/.
    PZ

  • The application "PREVIEW" can't locate files, cancels shutdown. How can I remove these files from PREVIEWS memory?

    Does anyone know how I can stop this program from looking for files? Every time I restart PREVIEW gives two errors while it's searching for image files that are no longer there. FYI this is a lingering problem related to the replacement of my hard drive (under recall from apple), iphoto had to be totally rebuilt many times through technical support. Now there's just this program still trying to open phantom images.

    If you prefer to make your user library permanently visible, use the Terminal command found below.
    http://osxdaily.com/2011/07/04/show-library-directory-in-mac-os-x-lion/
    You might want to bookmark the command. I had to use it again after I installed 10.8.2. I have also been informed that if you drag the user library to Finder it will remain visible.

  • How can i download many file from server one times.

    Hi,
    I want to create the service to download multi-files from web server one time
    from browser. It seems no way to do it. My soulition is compressing the files
    to zip before download it. The problem is that when the user uncompresses the
    files,full path of downloaded files are setted. Look like this:
    /usr/tmp/test/file1
    /usr/tmp/test/file2
    /usr/tmp/test/file3
    My question is :
    1. Is there any way not to specify the full path of a file when
    add the file to zip.
    Here is the source
    BufferedInputStream bis
    = new BufferedInputStream(
    new FileInputStream( file ) );
    //if not full path . can is works?????
    ZipEntry target = new ZipEntry( file.getPath() );
    // zos is ZipOutputStream
    zos.putNextEntry( target );
    int c;
    while( ( c = bis.read() ) != EOF ) {
    zos.write( (byte)c );
    2. Is there any way to get and change the current work directory of my server ?
    Please help!!

    If i use file.getName(). I will lost the struct of path.
    I means that,if i compress the list of files:
    /usr/tmp/test1/file1
    /usr/tmp/test1/file2
    /usr/tmp/test2/file3
    can i keep the part of path's strcut. (usr/tmp/../.. etc.)
    I tried to do as this:
    target = new ZipEntry( file.getPath.substring(1));
    an error be reported when uncompressed the zip file.
    error message:
    warning [zt000002.zip]: extra 28 bytes at beginning or within Zip file (attempting to process anyway)
    Error in file #1: bad Zip file offset (Error local header signature not found): 0
    (attempting to re-compensate)
    Extracting 20030109.xls
    Error: unexpected end of file encountered
    Error: invalid compressed data to inflate
    Why? can i set "any" entry name??

  • How can I remove these files? - Nokia 5310

    So, I bought a Nokia 5310, configured it, yada yada, everything's working fine.
    My memory card, oddly enough, came with an extra folder ironically titled "Extra"
    This folder has 5 songs in it, all of which I am not interested in and want OFF my phone.
    Anyways, long story short, it won't let me. Not on the phone, not through the PC software, not through explorer, these files are "write-protected", and I can't even move them around! Frustratingly enough, they take up space, and end up in my players library.
    ALSO, I want to get rid of,the default tones and whatnot the phone came with. There's like, 40 of them! And it makes for unnecessary menu drilling.
    Thanks!!

    19-Sep-2008 10:10 PM
    kombat_911 wrote:
    (What do you mean "stuck" with Windows? lol)
    There are alternative operating systems that run on a PC and that are far more stable, flexible and powerful than Windows. Of the dozens of such operating systems, I mostly use FreeBSD, Solaris and various variants of Linux on my machines, thus I am not "stuck" with that bloatware called Windows.
    I'll say no more on that matter though - I don't want this topic to turn into an OS war
    Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you!

  • HT2531 How can Spotlight find a file in the Library (in an app's plugin folder)?

    I'm writing a plugin for SketchUp that lives in SketchUp's plugins folder in the system Library.  Even when I put an alias of the plugins folder out on the desktop, Spotlight can't seem to find it (my plugin file).  I've learned the trick of using the option key to reveal the Library folder in the Go menu, but why does the file remain 'hidden' from Spotlight after I've drug an alias of its folder out to the desktop?
    I also tried using Terminal to patch Hidden to NoHidden without reliable results.  Yuck.
    Thanks for any help you can offer,
    John Trotter

    To view system and hidden files, use the Finder (cmd-F) to find.
    From the criteria popup menu, select Other...
    From that list that pops up, find System Files and Visibility; check both so they stay in the menu.
    When searching for system files or hidden files, use those criteria.

  • How can I change the db connection for may BC4J/JSP app

    I have connection information stored in the database.
    May I set a first connection and then change it for my application module???
    I can't find any method for this.
    TAD
    mauro

    Hi,
    Have you checked out the HOWTO article at:
    http://technet.oracle.com/products/jdev/howtos/bc4j/howto_dynamic_jdbc.html
    The article shows how JDBC credentials etc may be passed at runtime to a pooled ApplicationModule. The article
    currently uses an example where a web client passes the credentials to BC4J. However, this approach could be
    extended/replaced with code that queries the credentials from another external source (DB/LDAP/etc).
    Hope this helps.
    JR

  • How does one remove temporary files from Safari?  A friend logged on to her Facebook account using my iMac.  Now I can't remove her e-mail address from Facebook.  It was suggested to me that I try clearing temporary files from Safari but I can't find

    How does one remove temporary files from Safari?  A friend logged on to her Facebook account using my iMac running Mac OSX 10.7.5 and Safari 6.1.6.  Now I can't remove her e-mail address from my computer.  When I open Facebook her address shows in the user button.  I do not have a Facebook account.  It was suggested to me that I try clearing temporary files from Safari but I can't find anything that tells me how to do this.  Are temporary files the same as the cache?  It also was suggested that I try clearing Safari cache.  How do I do that?

    Check Safari/Preferences/Passwords to see if the Facebook account is there. If so, select it and remove it. If you are still having problems, Safari/Preferences/Advanced - enable the Develop menu, then go there and Empty Caches. Quit/reopen Safari and test. If that doesn't work, Safari/Reset Safari.

Maybe you are looking for

  • How can I pass a value from one application to another through URL

    I am passing a value APP_USER from one application to another application (item is P_ASK_U) through navigation bar entrees URL. This is working with in the application..(javascript:popupURL('f?p=&APP_ID.:165:&SESSION.::&DEBUG.::P_ASK_U:#&APP_USER.#')

  • Itunes won't start up, missing folder.

    The folder "iTunes" cannot be found or created, and is required. The default location for this folder is inside the "My Music" folder. Above is the error message I get whenever I try to open iTunes. I've tried re-installing, I've tried manually creat

  • You Should Be Ashamed

    To the Adobe Help Team: You should be ashamed. Like many others I recently upgraded my CS6 suite. Much to my surprise when I installed the upgrade I was met with a completely re-written and broken HELP system. Any attempt to access the help through o

  • Audigy 2 ZS Platinum not decoding A

    I want to use my Audigy 2 ZS Platinum to decode AC-3 signals when I play DVDs. I have done everything the "Digital Connections, SPDIF and Dolby Digital Info" thread. I have verified the SPDIF passthrough is disabled in AudioHQ.. rather.. Use Installe

  • Order and Sales Reporting Documentation

    Hi, I have a client that is trying to decide if they will use the standard SAP Bi reporting method for orders where the cancellation is taken into account on the date of the original order OR to make the cancellation or change applicable on the DATE