File in docroot write protected

Hello,
I have a web program that uploads images into a directory in docroot. The program also displays the images on a web page and allows the user to delete the images.
I have noticed that even after the server displays the images, they are still write protected. I assume by the application server. So, my code to delete the files doesn't work. Does anyone know a resolution to this? I am open to ideas.
File F = new File(fileLoc);
if (f.delete() == false)
  System.out.println("Could not delete" + fileLoc);Thanks
Mike

I got an answer to this on the Glassfish forum. It appears to work. The app server can cache or not cache files in the docroot. Caching will set the write protection flag and thus make them impossible to delete.
To not cache, change the file-caching-enabled and globally-enabled to false in the build.xml
<http-file-cache file-caching-enabled="true" file-transmission-enabled="false" globally-enabled="true" hash-init-size="0" max-age-in-seconds="30" max-files-count="1024" medium-file-size-limit-in-bytes="537600" medium-file-space-in-bytes="10485760" small-file-size-limit-in-bytes="2048" small-file-space-in-bytes="1048576"/>
change to
set file-caching-enabled="false" and globally-enabled="false"

Similar Messages

  • How to detect the diskette is write protect?

    I would like to write a file to a diskette. Before that I would like detect the diskette is write protect or not? and prompt a meaningful message. Could anyone help? Thanks!

    Check the file API...there is a "canWrite()" method...I would assume this returns FALSE on a write protected disk. IF that does not work, then trying to write an actual file to a write protected disk would throw some kind of exception...which of course you can trap.

  • How can i remove write protection from a Hard drive

    Cant write to HDD on win7 keeps saying "the disk is write protected"  Drive is in a removable IDE caddy, I put the drive in a USB caddy and was able to format the drive, but still get the same error when i try to write to it, I took ownership of the drive and it shows me as the owner. The drive was used in XP previously but i no longer have an XP system since upgrading to Win7. I have removed the partition with Paragon drive copy and re partitioned the drive, renamed the drive but still gives the same error.

    I used succesfully diskpart (on my Windows 7).
    In "Command prompt" (Start -> Run -> cmd) type "diskpart" and press enter.
    (I wrote "cmd" and then on right click menu I clicked on "Run as administrator").
    In diskpart utility (in the same dos window) you have to type "list volume".
    You can see your disk (I see all my 4 partitions on the disk that give me the problem) with a progressive number index.
    Type "select volume #" and press enter, "#" is the number corresponding to your disk/partition.
    Wait the response.
    Then type "attributes disk clear readonly" and wait (I wait 2/3 minutes) for the result.
    It says that operation was completed, and I can write on my partitions (and run checking/scanning on it).
    Hi,
    The hard drive I had problems with had 3 partitions and at least one was write-protected. Just to make sure I used the above "diskpart" commands on each volume and it cleared the write-protected attributes and was able to format the 10Gb partition I used
    just for storing the Pagefile.sys file.
    The write-protect attribute on this WD AV 1Tb h/drive may have been added as it was previously used in my Foxtel IQ box. I used Ghost 11.5.1 to clone my failing WD 1Tb h/drive that had 1376 delays and 50 bad sectors when scanned with HDD Regenerator
    onto the previously used Foxtel IQ h/drive.
    Cheerz ;)
    Thanks again, I was pulling my hair out to find a solution.

  • Touch and sync related issues due to write protected photo's

    i had a problem where the photo's in the directory that the touch was pulling from were write protected. once sync'd the ipod gets an error every time thereafter seemingly becuase the files synced were write protected. if you turn of the sync photo's option, the photo's remain so that does not help. so i had to do a restore of my ipod touch. a few comments about this process. turning of automatically sync when connected does nothing (and either does {ctrl}{Shift} when connecting). for some reason, if a "verify" starts on the ipod, even if you delete the sync history, it must verify. this makes no sense since you will have to wait hours (as i did) for the verify to complete just to restore the ipod. the next morning when i actually told the system that it was a new ipod instead of restoring from backup (which i assume would only put the write protected photo's back on the ipod) i did all the settings again, etc. painful! this bug needs to be fixed. write protected files should not screw up your ipod or syncing. one final question, are there and licensing ramifications on a restore with a new setup (instead of from backup)? the older ipod name still shows in devices. is it safe to delete the backup at this point?
    thanks
    harvey

    I do not recall anyone else specifically mentions this but other users have reported problems with wifi sync and maybe that was the reason.

  • Delete file with write protection

    Hello,
    Is there any way to delete a file on Windows that is write protected? I have a web program that uploads images into a directory in docroot. The program also displays the images on a web page and allows the user to delete the images.
    I have noticed that even after the server displays the images, they are still write protected. I assume by the application server. It doesn't always do this, but sometimes. When it happens I have noticed that restarting the application server corrects it. So, my code to delete the files doesn't work. Does anyone know a resolution to this? I am open to ideas.
    File F = new File(fileLoc);
    if (f.delete() == false)
      System.out.println("Could not delete" + fileLoc);Thanks
    Mike

    Someone solved my problem on the Glassfish site. If you are using Glassfish, it can cache or not cache files in the docroot. Caching will set the write protection flag and thus make them impossible to delete.
    To not cache, change the file-caching-enabled and globally-enabled to false in the build.xml
    <http-file-cache file-caching-enabled="true" file-transmission-enabled="false" globally-enabled="true" hash-init-size="0" max-age-in-seconds="30" max-files-count="1024" medium-file-size-limit-in-bytes="537600" medium-file-space-in-bytes="10485760" small-file-size-limit-in-bytes="2048" small-file-space-in-bytes="1048576"/>
    change to
    set file-caching-enabled="false" and globally-enabled="false"

  • WIN7 x64 Home Basic, 0x80070013 when trying to write or delete files. Disk is write protected.

    Hi,
    My SD card reader is not able to write or delete and format sd cards.
    WIN7 x64 Home Basic, 0x80070013 when I trying to write or delete files. When I trying to format I can see a message that disk is write protected. 
    The card is not locked, it's work in Lenovo Idea Pad s10 without any problem, It's also work in my Pentax camera.
    I'm almost sure that the problem is software, but can't find solution.
    Could Any one help me please?
    Laptop is new, 8 days in use. 

    I have network shutdown 2.0.1 installed and the pcns process normally would be abend in 1 or 2 minute's time. What could be the problem ? Consider to upgrade the network shutdown to 2.2.1 version. Could the problem be resolved in new version ? Any precaution needs to be taken when installing the new version ?
    Terence.

  • How to delete a write protected file from nokia x7...

    There are some files that i need to delete from my nokia x7 phone memory.  ( one mp3 file and a photo). It says that the file is write protected. Pls advice me

    The files MAY be embedded within the Firmware .. Even NCC can't remove them ...
    The cost of Battery may vary according to Region. You may contact Nokia Care or Authorised dealers in your area to know the exact price ...Anyways to get the battery replaced you need to visit Nokia Care ..

  • Error message when finalizing...file already open with write protection

    I just created my first movie in i Movie. It's about 9 minutes long. When I tried to finalize it it worked for a couple of hours and then came up with a message "unable to prepare project for publishing because an error occurred (file already open with write protection)". What does this mean? I thought I had closed all the files I was using. There was no error number. I tried it 3 times and got the same message. Any thoughts would be greatly appreciated.

    AppleMan, I just checked that and it looks like Time Machine isn't open. I checked it by going to finder>applications>R click on time machine. It gave me the option to "open" which makes me think it's already closed. Is there somewhere else I need to be looking?
    I made another movie that was just a couple of clips and it finalized fine. On that movie, I had some MTS clips and I converted them to mp4's so iMovie could read them.
    In the one that didn't work I did clip one of the movies before I imported it into iMovie. It saved as a .mov instead of a .mp4. Would that make a difference? I checked all of the files and none of them are listed as locked, so I really don't get the "write protected" aspect of this error.

  • Can't un-write protect TDM files

    I am using the storage VIs to manipulate a TDM file that was created using the TDM header writer API. When I try to do any operations on it (specifically, deleting a channel), i get error -2561 "Data storage is write-protected.". I have checked the permissions on the file and they should be correct.
    I ran some tests and found that i can create a TDM file using the storage VIs and delete a channel without any issues. According to LabVIEW, the file created using this method has the same permissions of the problem file.
    Do you think this could be a bug with the TDM header writer VIs? Or am i missing something obvious?
    I have attached  files showcasing the issue.
    Thanks in advance for any help.
    Attachments:
    TDM test.zip ‏131 KB

    Bazookazuz-
    The standard is described in the Developer Zone described above.  TDM files are binary files written such that it follows a particular pattern.  That way the data can be easily retrieved and interpreted later.  It is written in the fashion to save disk space and to be created/modified quickly.  All TDM files acquiring data from multiple channels follow the same format alternating between each channel taking each sample (also described in the Developer Zone article).  By converting the data to End-to-End, it makes all the data for each channel together. 
    In order to distinguish between the modified and unmodified tdm files, there is no way to just look at the file type and know without a naming scheme.  Programmatically, you can parse out the first few data sets and see if they are the same channel and then you can determine from there. 
    Regards,
    Mike S
    NI AE

  • CAPL browser shows that the .can file is write protected while it is not and keeps toggling, CPU performance reach 100%

    The problem is when I open the CAPL browser, the CPU load increases to 99~100%, and the .can file I am editing can't be saved, and I keep getting the message "file is protected and can't be saved". This happened on multiple machines with different CANoe versions. 
    I tested on these versions: 
    8.0.36
    8.0.71
    8.0.93
    8.1.60
    Randomly the icon of the "write protected" appears beside the file name in the file tab inside the CAPL browser, if I could press the save button while it is not appearing the file is saved, other wise I get the error message. The memory usage is also increases too much and then the browser stop responding.
    Do any body had the same issue before? any advice?
    Operating system: Windows 7 Ultimate 64
    AntiVirus installed:  McAfee

    Hi Allaithy,
    Can you clarify how is this issue related to NI CAN products?
    Anyway, here are some things to try:
    Is this the file on a network? Do you have administrator privileges to this network?
    Is file set to Read-only?
    Miro T.

  • Adobe PDF (Print) presets: "Cannot create the file. The folder may be write protected."

    In Windows 8, this feature of InDesign CS6 only works for the local Administrator account:
    File -> Export -> Save as type: Adobe PDF (Print) -> Save -> Save Preset... -> OK
    If you try it with any other account this error message is given: "Cannot create the file. The folder may be write protected."
    For anyone else encountering this problem, a workaround is to run as administrator.

    Which permissions exactly did you set, how did you set them and what did you set them to?
    The path to the Drop Box would be /Users/someuser/Public/Drop Box but you obviously wouldn't want the ownership and permissions to be the same on all four directories.
    Have you tried using Disk Utility (/Applications/Utilities/Disk Utility) to repair permissions? That would probably be the best way to ensure they're correct.
    - cfr

  • Creative Zen 8GB - Can't delete certain files (Write Protected it sa

    I have added a bunch of mp3s, images and videos to my player, but now when I try to delete some of these files I get a "you can't delete this file because it's write protected", if I check the properties of such files they are infact write protected but there's no way for me to uncheck the box and make them deletable.
    Anyone with the same problem or with a handy solution?
    P.S. I updated already to the latest firmware.

    Yes; I got my Zen this week and had the same problem when I copied over some MP3 files from a CD-ROM, which are write protected when the CD-ROM is created. I thought that the Zen was defecti've but now feel this is either a programmers misunderstanding of Windows Read Only functionality in the Zen -or- when you protect a file from deletion within the Zen, this is what the firmware sets to flag the file as 'Protected (I have not researched this yet).
    My Fix: For some of you this will not be the answer you are looking for but it works and will kept your Zen music file structure and library intact.
    You may need to switch to MTP mode in the creative software before you are allowed to use this technique. Search the forum where to find this checkbox. Otherwise your XP may be able to nati'vely open Explorer windows to the Zen.
    Setup: Open two Windows Explorer windows on your desktop. In one, create a new folder on a hard dri've that has enough space to handle all the music files on your Zen. In another Explorer window, navigate to the Zen music folder.
    1. Use Windows Explorer to copy ALL of your music files From the Zen to a new folder on your computer's hard dri've. If you don't have enough room on your hard dri've (and if not, why don't you? ) move files in stages.
    2. When the files are in your hard dri've's folder, right-click on the new folder and select Properties. Deselect (Uncheck) the Read Only attribute checkbox. If another dialog is displayed, select "Apply changes to this folder, subfolders and files" and click 'OK'. This will make all your files deletable on the Zen.
    3. Copy (drag) all the files back to your Zen, overwriting the original files.
    That's it. In the future perform step two before copying any files to the Zen.
    -Winged One

  • Saving Non Write Protected Files?

    Hello Adobe Community!  My name is Ali, and I'm a (very!) novice user of Soundbooth CS5 for Windows.  I record a weekly podcast, and when I'm finished editing my show, I really like to transfer the file to iTunes and write the metadata.  In the past, I was able to find a setting in Soundbooth that allowed my files to be writeable, but recently I had to reinstall the program when my computer crashed, and now my settings are back to factory standard.  I've been trying for hours, but no matter what I do, I can't seem to save my .MP3 in a way that I can open the file in iTunes and do my ID3 edits.  The info area in iTunes (and in Windows Explorer) is just blocked.  In Soundbooth, I've tried Edit > Preferences > Metadata.  I've also tried several things within the metadata preferences.  I've tried editing my Adobe Sound Documents to allow for Flash Compatible saving.  No luck!  I know it's possible to publish a non-write-protected file, because I was able to acomplish this before my comptuer crashed and I had to reinstall.  I'm sure it's just a one-click fix, but I can't seem to get it.  Can you help?
    Thanks in advance,
    Ali

    Hi again!  Any thoughts?

  • [svn:bz-3.x] 15191: Minor update to the build. xml and only make files write protected with chmod.

    Revision: 15191
    Revision: 15191
    Author:   [email protected]
    Date:     2010-04-01 07:06:21 -0700 (Thu, 01 Apr 2010)
    Log Message:
    Minor update to the build.xml and only make files write protected with chmod.
    Modified Paths:
        blazeds/branches/3.x/modules/sdk/build.xml

    DyNamic I agree that is sounds like you may be facing a network configuration issue.  Please let your network people know that you need access to the following servers and ports to download Adobe applications through the Adobe Application Manager:
    ccmdls.adobe.com:443
    ims-na1.adobelogin.com:443
    na1r.services.adobe.com:443
    prod-rel-ffc-ccm.oobesaas.adobe.com:443
    lm.licenses.adobe.com:443
    In addition for updates to download properly you will also need access to the following servers:
    http://www.adobe.com/:80
    htttp:///swupmf.adobe.com/:80
    http://swupdl.adobe.com/:80
    http://crl.adobe.com/:80

  • Copying Write protected files!

    Hi
    I Have some training QT movies that I want to put on my ipod. However, the files wont copy to my desktop.
    Any ideas how can get over this. I know ordinarily that QT movies are sometimes copy protected because the author doesn't want them copied! But this is a case of those who steel movies messing it up for the rest of us.
    I am not a t my computer most of the time, but I always have my ipod with me.
    Any solutions?
    Thanks
    Trevor

    If the files are protected (DRM) there is nothing you can do but watch them the way the author intended.
    Even discussing methods of breaking DRM is against the rules of these pages.
    If you're trying to move "write" protected files that is an issue of permissions.
    Are the videos on a CD or inside a Disk Image?

Maybe you are looking for

  • TS3899 mail, contacts and calendars do not open in my Ipad

    When I press contacts it close immediately and I canot open the Mail, Contacts and Calendars in the settings. Please help me

  • Buzz or Hum in Audio Port

    My MacBook Pro has a low-level hum or buzz coming out the audio port whenever sound is coming out of it, and for 25 seconds more.  Then it stops. The noise sounds a bit like the 60-Hz hum or 120-Hz buzz from tube amps, but it occurs even when my MacB

  • BI7.0_WAD3.X - Pie Chart- Always shows 2 decimal point

    Hi, <u>Info:</u> <u> BI 7.0, Stack 10, FE 1100, WAD 3.X</u> <u><b>Problem 1: (Pie Chart) :</b></u> : a. I am unable to  make the Pie chart show percentage in one decimal point. (EG:  56.3%). b. The Pie chart does not have the selection to show both v

  • Where i can get J2ee Software???

    I wish to develop J2EE applications.. First I installed Java JDK and ANT tools.. now i am in need of J2EE kit... I download the AppServer from java.sun.com.. Is it enough? or i have to download the J2ee software seperately.. Plase guide me... Wheneve

  • How to handle empty variable in BPEL Assign.

    Hello , I am using SOA 11g R1 I have created one Human task with task Details. Also i am assigning the Usercomments/task/comments to onw of my variable, but if I dont provide the comments from worklist comments section, and approves the task, My Assi