Originally posted by Ashok Mudgapalli:
You are right, I would like to report any errors before I close the window. In my case, I use servlet to save the user's data to database. After successful save, I would like the servlet to emit window.close() response.
How I can emit a window.close() as part of the response of the servlet? Could you please provide some details?
Thanks
After you have saved the data.
Use
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Confirmation.jsp");
rd.forward(request,response);
in your servlet to direct the request response to confirmation page, say, confirmation.jsp page.
Where confirmation.jsp will be used to display your result.
Put this simple line in your confirmation.jsp to close the window
------------
<a href="javascript:window.close()">Click here</a> to close this window.
------------