how to delete uploaded file .

hi every bode please help me in this context , I have successfully uploaded files and have simultaneously listed these files in the next page as a table data . now i want t provide alink for delete . I am not able to implement the deletemechanism

Please pass your valueable suggestions .

with regards

Ashutosh joshi

[342 byte] By [joshiashutosha] at [2007-11-27 5:51:10]
# 1
Checkout the [url= http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html]java.io.File API[/url]. It provides a delete() method.
BalusCa at 2007-7-12 15:39:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

yes sir the same i used to write a console program and it was working , the problem i am facing is how to incorporate the same to a scriplet . for your ease i am quoting the code here

String savepath ="/home/trainee/ashutosh/project/uploadedfiles/";

File my = new File(savepath);

String[] upload=my.list();

out.println("<center>");

out.println("<table border=1 cellpadding=1 cellspacing=2 width='50%'><th><font size=3 colo

r=blue><strong>S.No</font></th><th><font color='blue' size=3><strong>FileName</font></th><th>&nb

sp;</th>");

for(int i=0;i<upload.length;i++)

{

String name= upload;

out.println("><tr><td align=center>");

out.println((i+1));

out.println("</td><td align=center name='file'><a href='uploadedfiles/"+name+"'>");

out.println( upload);

out.println("</a></td><td align=center><form action=" delete.jsp" method='POSt'/>");

out.println("<input type=submit value='Delete'/></td></form></tr>");

out.println("</form></center></table>");

%>

delete.jsp

%@ page language="java" %>

<%@ page import="java.io.*"%>

<html>

<body>

<%

try

{

String name= request.getParameter("file");

String savepath="/home/trainee/ashutosh/project/uploadedfiles/";

String path=savepath+name;

File my = new File(path);

my.delete();

out.println("file"+ my+" deleted");

}

catch(Exception e)

{

out.println(e.toString());

}

%>

</body>

</html>

joshiashutosha at 2007-7-12 15:39:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...