You can set the redirect page with a filter when the session expires
Copy Code code as follows:
public class Actionfilter extends HttpServlet implements Filter {
Private Filterconfig Filterconfig;
public void init (filterconfig config) {
this.filterconfig = config;
}
public void Dofilter (ServletRequest servletrequest, Servletresponse servletresponse, Filterchain FilterChain) throws Servletexception, IOException {
HttpServletRequest req = (httpservletrequest) servletrequest;
Servletrequest.setcharacterencoding ("Utf-8″");
HttpServletResponse res = (httpservletresponse) servletresponse;
String URL = Req.getrequesturi ();
Sysuservoimpl user = (Sysuservoimpl) req.getsession (). getattribute ("Sysuser");
if (null = = user) {
if (! Common.isempty (URL) && (Url.endswith ("newestlogin.jsp") | | | url.endswith ("userloginaction.jsp") | | Url.endswith ("login.jsp") | | Url.endswith ("Loginaction.do"))) {
Filterchain.dofilter (ServletRequest, servletresponse);
} else {
Req.getrequestdispatcher ("/newestlogin.jsp"). Forward (req, res);
}
} else {
Filterchain.dofilter (ServletRequest, servletresponse);
}
}
But this can not not jump out of the framework such as IFRAME.
You can use JavaScript to solve
Add the following code to the page where you want to control the jump, such as the
Copy Code code as follows:
<script language= "JavaScript" >
if (Window!= top)
Top.location.href = Location.href;
</script>
JS Refresh Frame Script statement
Copy Code code as follows:
//How to refresh the page containing the frame
<script language=javascript>
& nbsp; parent.location.reload ();
</script>
//Child Windows Refresh parent window
<script language=javascript>
Self.opener.location.reload ();
</script>
(or <a href= "javascript:opener.location.reload ()" > Refresh </a> )
// How to refresh the page for another frame with
<script language=javascript>
parent. Another FrameID.location.reload ();
</script>
If you want to refresh when you close the window or refresh when you want to open it, call the following statement in <body>.
<body onload= "opener.location.reload ()" > Refresh when windows open
<body onunload= "opener.location.reload ()" > Refresh when closed
<script language= "JavaScript" >
window.opener.document.location.reload ()
</script>