-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathandroidrun.jsp
More file actions
61 lines (56 loc) · 1.79 KB
/
androidrun.jsp
File metadata and controls
61 lines (56 loc) · 1.79 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
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.json.JSONObject"%>
<%!
int success=0;
%>
<%
String temp_name=request.getParameter("name");
String path="";
String st2="";
String st1="";
String code="",fileName="";
int y=0;
File f;
%>
<%
y=1;
String uploadPath = getServletContext().getRealPath("/").replace("\\", "/");
if(!uploadPath.endsWith("/"))
uploadPath = uploadPath+"/";
uploadPath = uploadPath+"files/"+temp_name+"/";
st1=request.getParameter("filename");
int dot=st1.indexOf(".");
String classFile='"'+uploadPath+'"';
classFile=classFile.trim();
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)>0)
{
st2 +=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)>0)
{
st2 +=String.copyValueOf(x3,0,50);
x3=new char[50];
}
isr3.close();
out.println(classFile);
// out.println(st2);
JSONObject obj=new JSONObject();
obj.put("run", st2);
out.println(obj);
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>