forked from m0ver/tinystruct-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.java
More file actions
executable file
·59 lines (45 loc) · 1.1 KB
/
time.java
File metadata and controls
executable file
·59 lines (45 loc) · 1.1 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
package tinystruct.examples;
import java.io.IOException;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import org.tinystruct.AbstractApplication;
public class time extends AbstractApplication {
private static boolean stop;
@Override
public void init() {
// TODO Auto-generated method stub
this.setAction("time", "index");
this.setAction("time/update", "update");
this.setAction("time/start", "start");
this.setAction("time/stop", "stop");
}
public time index() {
return this;
}
public void start() {
stop=false;
}
public void update() throws IOException, InterruptedException {
HttpServletResponse response = (HttpServletResponse) this.context
.getAttribute("HTTP_RESPONSE");
while(true)
if (!stop) {
response.getWriter().println(
"<script> parent.update('" + new Date()
+ "');</script>");
response.getWriter().flush();
Thread.sleep(1000);
}else {
break;
}
}
public String stop() {
stop = true;
return "stopped!";
}
@Override
public String version() {
// TODO Auto-generated method stub
return null;
}
}