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
2010-10-04 10:09:41
+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
2010-10-04 15:56:09
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
2010-10-06 04:06:11