forked from skeeto/sample-java-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.jsp
More file actions
34 lines (33 loc) · 739 Bytes
/
count.jsp
File metadata and controls
34 lines (33 loc) · 739 Bytes
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
<html>
<head>
<title>JSP Demo</title>
</head>
<body>
<h1>JSP Demo</h1>
<%!
private int counter;
private synchronized int count() {
return ++counter;
}
%>
<%
String name = (String) session.getAttribute("name");
if (name != null) { %>
<p>Welcome back, <%= name %>.</p>
<form action="/logout" method="post">
<input type="submit" value="logout"/>
</form>
<%
} else { %>
<form action="login" method="post">
<input type="text" name="name"/>
<input type="submit" value="login"/>
</form>
<%
}
%>
<p>
This page has been visited <%= count() %> times.
</p>
</body>
</html>