0
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req.getSession(false);
if (session == null) {
String forwardTo = "/jsp/login.jsp?status=session";
ServletContext servletContext = filterConfig.getServletContext();
javax.servlet.RequestDispatcher dispatcher = servletContext
.getRequestDispatcher(forwardTo);
if (dispatcher != null) {
try {
dispatcher.forward(request, response);
} catch (Exception ex) {
ex.printStackTrace();
} catch (Throwable ex) {
ex.printStackTrace();
}
的web.xml如何設置會話超時中的servlet
<session-config>
<session-timeout>30</session-timeout>
</session-config>
istead 30我想獲得用戶偏好的時間。在這裏,我試圖setmaxinactive區間()方法,但我不知道我必須使用
沒有60分鐘不變。但是我必須設置一個動態值 –
60只是一個在運行時更改默認值的示例,與使用全局爲所有會話配置的web.xml不同。請解釋'用戶偏好時間'是什麼意思? – chenchuk
用戶必須提及會話超時時間.. 例如, 如果用戶優先選擇10分鐘作爲「會話超時」會話必須在10分鐘內過期 –