Tag: destroy

如何在Java Servlet中有效地破坏’session’?

我工作的Servlet有一个变量session 。 我试过session.invalidate(); ,这似乎已经破坏了会话,但是当我进行重定向时,如此response.sendRedirect(“restanes.jsp”); ,它为此行提供了HTTP Status 500错误: java.lang.IllegalStateException: getAttribute: Session already invalidated 这是因为我试图破坏会话。 但为什么页面无法重定向? 在其他地方的同一页上,我已成功重定向。 如何成功销毁会话和重定向? 代码段: if(request.getParameter(“logout”) != null ){ session.invalidate(); response.sendRedirect(“restanes.jsp”); } 更新:我需要做的就是return; 在response.sendRedirect(“restanes.jsp”); 。 衷心感谢BalusC 。

如何一次性从运行时中删除所有进程?

例如: Runtime rt = Runtime.getRuntime(); 创建Runtime rt Process p1 = rt.exec(“C:/Windows/System32/calc.exe”); 在Runtime rt上创建Process p1 。 然后是p1.destroy(); 将破坏Process p1 。 我的问题是:如果我有多个Process (例如p1 , p2和p3 ),我如何一次性销毁它们,而不是逐个销毁它们?

调用servlet的destroy方法

根据链接http://www.xyzws.com/Servletfaq/when-is-destroy-of-servlets-called/20 ,调用destroy方法的原因之一是当servlet没有得到请求时很长一段时间 我在想可能会有一些页面长时间没有被调用。 那么,这是否意味着销毁将被调用,它们将不再使用? 实际上,我在采访中被问到这个问题,他告诉我只有在服务器关闭时才会调用destroy方法。 感谢任何帮助。

什么时候被称为spring beans destroy-method?

我在bean的“destroy-method”中放了一个sysout语句。 当我运行示例代码时,sysout没有得到输出。 这是否意味着破坏方法没有被调用? 测试类: package spring.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class InitTest { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext(“InitTestContext.xml”); InitTestBean bean = (InitTestBean)ctx.getBean(“InitTestBean”); bean.display(); } } 豆 package spring.test; public class InitTestBean { private String prop1; private String prop2; public InitTestBean(String prop1, String prop2) { System.out.println(“Instantiating InitTestBean”); this.prop1 = […]