简体   繁体   中英

How to redirect to main page with in frame from servlet?

I have 3 frames in screen , using frameset I did like this.

index.thml

<frameset rows="75%,25%">
    <frameset cols="20%,80%">
        <frame src="TreeGroup.jsp" name="left" id="f1"/>
        <frame src="DisplayMap.jsp"   name="top" id="f2"/>
    </frameset>
    <frame src="Tabs.jsp" name="bottom"/>
 </frameset>

in frame f1 there is a link, if I click that , it opens VehicleReg in frame f2 . In frame f2 I click submit, control goes to Servlet and servlet redirect to index.html. Here is I am facing problem ,

In Servlet I do as response.sendRedirect("index.html")

but in Browser, It is already in index.html , after servlet response in frame f2 it opens index.html . I mean it redirects index.html with in frame f2 . How to avoid this. I want after servlet response a fresh index.html . Can anyone help me in this please.

Add the following JavaScript code between the <head> tags of your index.html page.

<script type="text/javascript" language="JavaScript">
    if (top.location != self.location) {
      top.location.href = self.location.href;
    }
</script>

This makes your index page automatically break out of the frames and reload itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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