简体   繁体   English

如何关闭servlet中的弹出窗口并将servlet重定向到父窗口

[英]How to close pop up window in servlet and redirect the servlet to parent window

i am creating a pop up window through jsp and passing some selected values in pop up window to jsp. 我正在通过jsp创建一个弹出窗口,并将一些在弹出窗口中的选定值传递给jsp。 while doing this i am using servlet ie. 同时我正在使用servlet即。 from pop up window i am calling servlet and in servlet i am using request dispacher and forwarding the result to jsp. 从弹出窗口中,我正在调用servlet,在servlet中,我正在使用请求调度程序并将结果转发到jsp。 this whole process is working fine, but the new jsp which i am calling from servlet is coming in the same pop up window. 整个过程运行良好,但是我从servlet调用的新jsp出现在同一弹出窗口中。 how can i close the pop up window in servlet and redirect the servlet to parent window. 如何关闭servlet中的弹出窗口并将servlet重定向到父窗口。

how can i close the pop up window in servlet and redirect the servlet to parent window. 如何关闭servlet中的弹出窗口并将servlet重定向到父窗口。

You cannot do this from the servlet side on. 您不能从servlet方面进行此操作。 You have 2 options: 您有2个选择:

  1. Just do not call the servlet from the popup window, but from the parent window. 只是不要从弹出窗口中调用servlet,而是从父窗口中调用。 The popup window should basically only contain some additional data or info and always be closed by JavaScript when it has done its job. 弹出窗口基本上应该只包含一些其他数据或信息,并且在完成工作后始终由JavaScript关闭。 The enduser should continue navigating/submitting from the parent window. 最终用户应继续从父窗口导航/提交。

  2. Let the servlet return a piece of JS code which does roughly the following: 让Servlet返回一段JS代码,大致执行以下操作:

     window.opener.location = 'newpage.jsp'; // Sets parent window's new URL. window.close(); // Close the popup window. 

    This is however an ugly hack. 但是,这是一个丑陋的hack。

传递到servlet回调方法(javascript),该方法将关闭弹出窗口并在父窗口中处理响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM