Article:
  Using the Jakarta Commons, Part 1
Subject:   Access Denied error
Date:   2006-03-01 13:42:13
From:   arunkotte
I am using similar code to upload my files in jsp. The images are uploading fine, But i am getting the Http 404 access denied error.


HTTP Status 404 - C:\Tomcat 5.5\webapps\start2finish\ImageUploads (Access is denied)


Any help will be greatly appreciated:


Here is the code sniipet:


<%

System.out.println("Content Type ="+request.getContentType());


DiskFileUpload fu = new DiskFileUpload();
// If file size exceeds, a FileUploadException will be thrown
fu.setSizeMax(-1);


List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();


while(itr.hasNext()) {
FileItem fi = (FileItem)itr.next();


//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {
System.out.println("\nNAME: "+fi.getName());
System.out.println("SIZE: "+fi.getSize());
//System.out.println(fi.getOutputStream().toString());
File tempFileRef = new File(fi.getName());

//Create a new directory
File testDir = new File("C:\\Tomcat 5.5\\webapps\\start2finish\\ImageUploads");
if ( !testDir.exists() ){
testDir.mkdirs();
}


//application.getRealPath("/")
//"C:\\Tomcat 5.5\\webapps\\start2finish\\ImageUploads"

if (fi.getName() != "") {
File fNew= new File("C:\\Tomcat 5.5\\webapps\\start2finish\\ImageUploads", tempFileRef.getName());


System.out.println(fNew.getAbsolutePath());
fi.write(fNew);
}
}
else {
System.out.println("Field ="+fi.getFieldName());
}
}


%>

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Access Denied error
    2006-03-01 15:52:18  gvix [View]

    This must have something to do with access rights over the file system. Check that you have write access in the folder that you are trying to download the file to.

    HTH,
    Vikram