How do I open and redirect to a popup window from a servlet? (Under certain circumstances I want my servlet to bust out of the frames and redirect to another servlet or page.)

Brett Knights

You can't do this directly but it is easy to do indirectly using JavaScript.

Essentially you return a page that has as its onLoad event code that opens a page and gets your new data.

Your servlet would create or return a page that contains:

<script language="javascript">
function bustOut(){
   var newWin ="the real url", ....); // params and stuff

window.onLoad = bustOut; //this should work but often doesn't. Lack of parens () is correct.
<body onLoad="bustOut()">

Eat at Joe's

You could set this up as a static html page to redirect to with "the real url" being encoded in a query string.

If you are unclear as to how to read the query string using JavaScript I'd recommend a good JavaScript reference. O'Reilly (who else) publishes two good books that would help with this: Javascript: The Definitive Guide by David Flanagan and Dynamic HTML by Danny Goodman

About | Sitemap | Contact