Menu

[r319]: / trunk / php-java-bridge / examples / php+jsp / sessionSharing.jsp  Maximize  Restore  History

Download this file

19 lines (16 with data), 550 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<HTML>
<TITLE>PHP and JSP session sharing</title>
<BODY>
<%
javax.servlet.http.HttpSession $session = request.getSession();
if($session.getAttribute("counter")==null) {
$session.setAttribute("counter", new java.lang.Integer(1));
}
int $counter = ((java.lang.Integer)$session.getAttribute("counter")).intValue();
out.println ("HttpSession variable \"counter\": " + $counter + "<br>");
java.lang.Integer $next = new java.lang.Integer($counter+1);
session.setAttribute("counter", $next);
%>
<a href="sessionSharing.php">PHP page</a>
</BODY>
</HTML>