-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelete_files.jsp
More file actions
52 lines (43 loc) · 1.64 KB
/
delete_files.jsp
File metadata and controls
52 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<%@page import="java.sql.*"%>
<%@page import="java.io.File"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="common/connection.jsp" %>
<!DOCTYPE html>
<%!
Statement statement;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<%
String filename=request.getParameter("filename");
String name=(String)session.getAttribute("userid");
try
{
//fileName=getServletContext().getRealPath("/").replace("\\","/")+"/"+name+ "/"+filename;
String uploadPath = getServletContext().getRealPath("/").replace("\\", "/");
if(!uploadPath.endsWith("/"))
uploadPath = uploadPath+"/";
uploadPath = uploadPath+"files/"+name+"/";
String filePath=uploadPath+filename;
File f=new File(filePath);
f.delete();
String classfile=filename.substring(0,filename.indexOf("."))+".class";
filePath=uploadPath+classfile;
File f1=new File(filePath);
if(f1.exists())
f1.delete();
statement=con.createStatement();
statement.executeUpdate("delete from compiledfiles where file_name='"+filename+"'");
}
catch(Exception e)
{
}
request.getRequestDispatcher("Files.jsp").forward(request, response);
%>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>