简体   繁体   English

使用jsp / servlet的iframe中的会话注销页面问题

[英]session logout page issue in iframe using jsp/servlet

Hi i'm working in the web application using jsp/sevlet,i'm facing the session logout page issue in iframe 嗨,我正在使用jsp / sevlet在Web应用程序中工作,我正面临iframe中的会话注销页面问题 样本网页

i use the following code in my parent page for my session time out 我在父页面中使用以下代码进行会话超时

<script type="text/javascript">
    idleTime = 0;
    $(document).ready(function () {
        //Increment the idle time 2ounter every minute.
        var idleInterval = setInterval("timerIncrement()", 60000); // 1 minute

        //Zero the idle timer on mouse movement.
        $(this).mousemove(function (e) {
            idleTime = 0;
        });
        $(this).keypress(function (e) {
            idleTime = 0;
        });
    })
    function timerIncrement() {
        idleTime = idleTime + 1;
        if (idleTime == 15) { // 15 minutes
           window.location = "logoutPage.jsp"
        }
    }
</script>​​​​​​​​​​​​​​​​​​​​

the issue i'm facing is , in case a process is running beyond the session time limit in the my iframe page then the parent page is idel so it automatically getting logout 我面临的问题是,如果某个进程的运行时间超出了我的iframe页面中的会话时间限制,则父页面为idel,因此它会自动注销

in other case if i use the session time out code in the my iframe page then the issue is 在其他情况下,如果我在iframe页面中使用会话超时代码,则问题是 示例页面2

the logout page is coming inside the iframe page 注销页面进入iframe页面

Any suggestions or other explanations for solving this mystery? 对于解决这个谜题有什么建议或其他解释吗? Please let me know 请告诉我

Finally i found the solution for Iframe issue 最后,我找到了iframe问题的解决方案

Automatically break out of an iframe 自动脱离iframe

Iframe stands for inline frame. iframe代表嵌入式框架。 An Iframe is a floating frame that can be inserted anywhere within a web page. Iframe是一个浮动框架,可以插入网页内的任何位置。

A concern for webmasters about iframes is that an iframe can be used to include pages on your website into external sites. 网站管理员对iframe的关注是,iframe可用于将您网站上的页面包含到外部网站中。

How do you prevent pages on your website from being included through an iframe by another website? 您如何防止其他网站通过iframe包含您网站上的网页?

Placing the following javascript code at the top of all pages on your site will ensure that if any other site iframes a page on your website, that your page will break out of the iframe and just display your page in the users browser. 将以下javascript代码放在您网站上所有页面的顶部,可以确保如果其他网站对您网站上的某个页面进行了内嵌框架,则该页面将脱离iframe,仅在用户浏览器中显示您的页面。

<script type="text/javascript">
<!--
    if (top.location!= self.location) {
        top.location = self.location.href
                   //or you can use your logout page as
                   //top.location='logout.jsp' here...
    }
//-->
</script>

The best way to implement this break out of an iframe code on an entire site is to put the code into an external javascript file, and include it in a common template file.. 在整个网站上实现这种iframe代码突破的最佳方法是将代码放入外部javascript文件,并将其包含在通用模板文件中。

This will be useful for the buddies who fraught with these kind of mystery..... 这对于那些充满这种神秘感的伙伴很有用.....

Try this if you think it is ok. 如果您认为还可以,请尝试此操作。

Put the iframe in a different page and include that page in your main page using JSP's include tag. iframe放在其他页面中,并使用JSP的include标记将该页面包括在您的主页中。

Then try and see. 然后尝试看看。

I actually think iframe remains as a different from the parent page. 实际上,我认为iframe与父页面有所不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM