I am developing a small spring MVC application. When user logged in successfully, a welcome page will be displayed and when session timedout it ll auto redirect to login page. On welcome page I have a button, and onclick of button opens a popup window. Now after opening popup window if session timed out, my popup should close and parent page should redirect to login page. I have tried something with meta tag like below on parent page and popup window.
<meta http-equiv="refresh" content="<%=session.getMaxInactiveInterval()%>;url=login"/>
But it is not working. session is not getting timed out at all when popup is open. Page is auto refreshing, but session not getting expired even in parent page also.
Welcome Page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="refresh" content="<%=session.getMaxInactiveInterval()%>;url=login"/>
<title>Home page</title>
<script>
function popup() {
window.open("../Bank/register", 'window', 'width=200,height=100');
}
</script>
</head>
<body>
<h1>Welcome ${sessionScope.USER_NAME}..!</h1>
<c:if test="${sessionScope.USER_ROLE==1}">
<!-- <a href="register">Register</a> -->
<a href="#" onclick="popup()">Register</a>
</c:if>
<a href="logout">Logout</a>
</body>
</html>
Popup page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="refresh" content="<%=session.getMaxInactiveInterval()%>;url=login"/>
<title>Bank - Registration</title>
</head>
<body>
<form:form action="register" method="post" modelAttribute="register">
<table>
<tr>
<td><form:label path="username">User Name:</form:label></td>
<td><form:input path="username" name="username" id="username" /></td>
</tr>
<tr>
<td><form:label path="fName">First Name:</form:label></td>
<td><form:input path="fName" name="fName" id="fName" /></td>
</tr>
<tr>
<td><form:label path="lName">Last Name:</form:label></td>
<td><form:input path="lName" name="lName" id="lName" /></td>
</tr>
<tr>
<td><form:label path="password">Password:</form:label></td>
<td><form:password path="password" name="password" id="password"/></td>
</tr>
<tr>
<td><form:label path="Email">Email:</form:label></td>
<td><form:input path="Email" name="Email" id="Email" /></td>
</tr>
<tr>
<td><form:label path="phoneNo">Phone No:</form:label></td>
<td><form:input path="phoneNo" id="phoneNo" name="phoneNo"/></td>
</tr>
<tr>
<td><form:label path="IsAdmin">Is Admin:</form:label></td>
<td><form:checkbox path="IsAdmin" id="IsAdmin" name="IsAdmin" value="1"/></td>
</tr>
<tr>
<td><form:button id="reset" name="reset" onClick="document.forms[0].reset();">Reset</form:button></td>
<td><form:button id="register" name="register">Register</form:button></td>
</tr>
</table>
</form:form>
<table align="center">
<tr>
<td style="font-style: italic; color: red;">${Message}</td>
</tr>
</table>
</body>
</html>
If I am not using popup window and use just URL redirect in seperate tab, it is working fine. But I had to use popup. Please help me with this.