开发者

How to set a JSP target to parent frame in Struts2?

开发者 https://www.devze.com 2023-03-02 19:41 出处:网络
In my web application, the开发者_Python百科re is one page(.jsp) which is divided into three frames. AddCp.jsp is in one frame of that JSP. Now on session timeout I want to show login page again. But t

In my web application, the开发者_Python百科re is one page(.jsp) which is divided into three frames. AddCp.jsp is in one frame of that JSP. Now on session timeout I want to show login page again. But the problem is this that the login page is coming in that frame only not on the whole window.

Below is the code snippet from struts.xml:

<action name="AddCP" class="com.appupdate.action.AppUpdateAction" method="addCP">
        <result name="success">/WEB-INF/pages/AddCP.jsp</result>
        <result name="login" type="redirectAction">
            <param name="actionName">showLogin</param>
            <param name="namespace">/login</param>
            <param name="navigation">timeout</param>
            <param name="target">_parent</param>
        </result>
    </action>

Could anyone please help? How can I change the target frame here?


The request should specify the target, response doesn't have any way to change it. You are getting that loaded in the frame from where request was initiated.

[Edited]

To confirm this, you can refer to this JavaRanch thread.


Solution:

You can have a JavaScript statement in your login.jsp.

<script>
    if(parent.frames.length > 1)
        parent.location.href = '/showLogin';
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消