tags:

views:

42

answers:

3

hello; i have a jsp page that checks a query if the answer is true the program goes to a servlet page otherwise the program continue as planned my question is: if i do go to the servlet page how can i close the original jsp page from the servlet

+1  A: 

you can do it using javascript, and make them execute when your condition satisfy

org.life.java
+1  A: 

You can not close browser window from the servlet.

But you can close window using javascript.

For example write something like:

<body onLoad="closeWindow(<% bean.isCloseWindow %>)">

And in javascript function "closeWindow" do something like this:

function closeWindow(ifClose) {
if (ifClose) {
window.close();
}
}
Andriy Sholokh
A: 

It's true that you can close a window using JavaScript's window.close(), but the window will only be closed when the window is opened by your application using window.open() and not when it is opened by the enduser itself (e.g. by a link, form submit, bookmark, etc).

BalusC