-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheditorrun.jsp
More file actions
67 lines (60 loc) · 1.95 KB
/
Copy patheditorrun.jsp
File metadata and controls
67 lines (60 loc) · 1.95 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<%@page import="java.io.*"%>
<html>
<body>
<%
session=request.getSession(false);
String name=(String)session.getAttribute("userid");
String path="";
String st2="";
String st1="";
String code="",fileName="";
int y=0;
File f;
if(session==null)
{
request.getRequestDispatcher("index.jsp").forward(request, response);
return;
}
%>
<%
y=1;
//request.setAttribute("action", "run");
String uploadPath = getServletContext().getRealPath("/").replace("\\", "/");
if(!uploadPath.endsWith("/"))
uploadPath = uploadPath+"/";
uploadPath = uploadPath+"files/"+name+"/";
st1=request.getParameter("filename");
int dot=st1.indexOf(".");
String classfile='"'+uploadPath+'"';
try
{
Process pro1=Runtime.getRuntime().exec("java -cp "+classfile+" "+st1.substring(0, dot));
//out.println(f.getAbsolutePath());
InputStreamReader isr2=new InputStreamReader(pro1.getErrorStream());
char [] x2=new char[50];
while(isr2.read(x2)>-1)
{
st2 +="\n"+String.copyValueOf(x2,0,50);
x2=new char[50];
}
isr2.close();
InputStreamReader isr3=new InputStreamReader(pro1.getInputStream());
char [] x3=new char[50];
while(isr3.read(x3)>-1)
{
st2 +="\n"+String.copyValueOf(x3,0,50);
x3=new char[50];
}
isr3.close();
out.println(classfile);
out.println(st2);
request.setAttribute("runfile", st2);
request.getRequestDispatcher("Editor.jsp").forward(request, response);
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body>
</html>