Thanx for giving ur invaluable time to my question.
I hv given a facility to a site user to upload some files..
And an interface to web administrator to view all the files..
I want to know how can i write a code in JSP which allow the web administrator to delete any of that file which is not of his/her interest through provided interface only.
Is is possible to delete a particular file from web server without getting login into FTP account
// choose the appropriate filepath
// you can also use File.separator for your slashes
// if you are building a dynamic path
String filePath = "c:\\tomcat\\webapps\\myapp
String filePath = "/usr/local/tomcat/webapps/myapp/myfile.txt";
// code to delete file :p
File f = new File(filePath);
// yes it's that easy...
so if you already have a listing of files, simply provide a URL link to each file or a form listing and then have it go to your controller... so you can have:
File f = new File(request.getParameter("filePath");
or build a dynamic file path
String filePath = getServletContext().getRealPath("") + File.separator + "WEB-INF" + File.separator + "uploads" + File.separator + request.getParameter("fileName");
I think you get my drift... but the code to delete is simple...