It seems to me that a JSP page forward always ends up in the frame where the original JSP page was in. How can I replace the entire frame with a new page?

Michael McElligott

Unfortunately, your JSP application has no way of knowing that it's being loaded into a frameset - your forward will always be loaded into the browser in the place that the original request would have gone. One solution I'm aware of is to write a small snippet of javascript changing the document location to your new location. So that, instead of doing a response.forward(String f) you would instead place something like:

out.println("<script language='javascript'>");
out.println(" top.document.location = " + f + ";");
out.println("</script>");

Actually, "top" might be the wrong keyword, but you get the idea (obviously, if you want the change to a peer frame, you have to navigate up to it in your Javascript - parent.peer.document.location = "foo.jsp").

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact