-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEditor.jsp
More file actions
204 lines (169 loc) · 5.28 KB
/
Copy pathEditor.jsp
File metadata and controls
204 lines (169 loc) · 5.28 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<!DOCTYPE html>
<html>
<%
String action = (String)request.getAttribute("action");
session=request.getSession(false);
String name=(String)session.getAttribute("userid");
String st="";
String st2="";
String st1="",st3="";
if(session==null)
{
request.getRequestDispatcher("index.jsp").forward(request, response);
return;
}
%>
<% st2= (String)request.getAttribute("compile");
st3=(String)request.getAttribute("runfile");
%>
<%!
String filename="";
%>
<%
filename=request.getParameter("filename");
String code=request.getParameter("Code");
if(code==null && action!=null)
{
String uploadPath = getServletContext().getRealPath("/").replace("\\", "/");
if(!uploadPath.endsWith("/"))
uploadPath = uploadPath+"/";
uploadPath = uploadPath+"files/"+name+"/";
String filePath=uploadPath+filename;
try
{
File f = new File(filePath);
System.out.println(f.exists());
BufferedReader input = new BufferedReader(new FileReader(filePath));
String line = "";
while ((line = input.readLine()) != null)
{
code+="\n"+line;
}
input.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
%>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css" type="text/css">
<!--[if IE]>
<link rel="stylesheet" href="css/ie.css" type="text/css" charset="utf-8">
<![endif]-->
</head>
<body>
<form action="editorsavefile.jsp" method="post">
<div id="background">
<div id="page">
<div id="header">
<ul id="navigation">
<li class="selected">
<a href="Home.jsp">Home</a>
</li>
<li>
<a href="Editor.jsp">Editor</a>
</li>
<li>
<a href="Files.jsp">Files</a>
</li>
<li>
<a href="Logout.jsp">LogOut</a>
</li>
<li>
<a href="Download.html">App Download</a>
</li>
</ul>
</div>
</div>
<div id="contents">
<div id="sidebar">
<h2>Output</h2>
<div>
<div class="section">
<div class="body">
<p>
<pre>
<%
if(st2!=null)
out.println(st2);
if(st3!=null)
out.println(st3);
else
{
}%>
</pre>
</p>
<span></span> <span class="author"> </span>
</div>
</div>
</div>
</div>
<div id="featured">
<h2>Java </h2>
<p>
<p>
<label for="Code"></label>
<textarea name="Code" id="Code" cols="100" rows="20" ><%=code %></textarea>
</p>
<p>
<label for="filename"></label>
<input type="text" name="filename" id="filename" value="<%=filename %>" size="20"/>
<p>
<input type="hidden" name="filename" value="1" />
<input type="submit" name="submit" id="save" value="Save" /></form> </form>
<form action="editorcompile.jsp" method="post">
<input type="hidden" name="filename" value="<%=filename %>" />
<input type="submit" name="compile" id="save" value="Compile" />
</form>
<form action="editorrun.jsp" method="post">
<input type="hidden" name="filename" value="<%=filename %>" />
<input type="submit" name="save" id="save" value="Run" />
</form>
<ul>
<li>
</li>
<li>
<span><a href="" class="more">All Programs</a></span>
</li>
</ul>
</div>
</div>
</div>
<div id="footer">
<div>
<ul>
<li>
<h4>Links</h4>
<ul class="navigation">
<li>
<a href="Home.jsp">Home</a>
</li>
<li>
<a href="Editor.jsp">Editor</a>
</li>
<li>
<a href="Files.jsp">Files</a>
</li>
<li>
<a href="Download.html">App Download</a>
</li>
</ul>
</li>
</ul>
<p id="footnote">
© Copyright Jitendra Kumar. All rights reserved.
</p>
</div>
</div>
</div>
</div>
</body>
</html>