Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重写jspDestroy()以关闭Java EE中的会话_Jsp_Session_Jakarta Ee - Fatal编程技术网

重写jspDestroy()以关闭Java EE中的会话

重写jspDestroy()以关闭Java EE中的会话,jsp,session,jakarta-ee,Jsp,Session,Jakarta Ee,我想在关闭应用程序窗口时删除会话。 我试图用session.setAttribute(“user”,null)覆盖jspDestroy();但是它不起作用。我想你误解了jspDestroy()的目的。此方法相当于Servletdestroy()方法。来自JSP 2.2规范中的示例: /** An example of a superclass for an HTTP JSP class */ abstract class ExampleHttpSuper implements HttpJspPa

我想在关闭应用程序窗口时删除会话。
我试图用session.setAttribute(“user”,null)覆盖jspDestroy();但是它不起作用。

我想你误解了
jspDestroy()
的目的。此方法相当于Servlet
destroy()
方法。来自JSP 2.2规范中的示例:

/** An example of a superclass for an HTTP JSP class */
abstract class ExampleHttpSuper implements HttpJspPage {

 /** What you are overriding */
 public void jspDestroy() {}

 final public void destroy() {
   jspDestroy();
 }

 final public void service(ServletRequest req, ServletResponse res)
        throws ServletException, IOException {
 //remainder elided
当JSP不再为请求提供服务时,将调用此方法。它与用户会话没有1-1关系


由于浏览器不保持与服务器的开放连接,因此在浏览器关闭时终止会话是一个更复杂的主题。您可以在的答案中阅读一些方法。

我认为您误解了
jspDestroy()
的目的。此方法相当于Servlet
destroy()
方法。来自JSP 2.2规范中的示例:

/** An example of a superclass for an HTTP JSP class */
abstract class ExampleHttpSuper implements HttpJspPage {

 /** What you are overriding */
 public void jspDestroy() {}

 final public void destroy() {
   jspDestroy();
 }

 final public void service(ServletRequest req, ServletResponse res)
        throws ServletException, IOException {
 //remainder elided
当JSP不再为请求提供服务时,将调用此方法。它与用户会话没有1-1关系

由于浏览器不保持与服务器的开放连接,因此在浏览器关闭时终止会话是一个更复杂的主题。您可以在的答案中阅读一些方法。

我想在关闭应用程序窗口时删除会话。为什么?它会在超时时自动发生。我想在关闭应用程序窗口时删除会话。为什么?它会在超时时自动发生。