开发者

How to set session max inactive time?

I get the session MaxInactiveInterval time using the following query. I am developing web application using JSF Framework

var sessionMaxInactiveTime = ${pageContext.session.maxInactiveInterval};

I need to set maxInactiveInterval.

how to set maxInactiveInterval using JavaScript, JQuery, or to write Servlet.

But i want to control to main template jsp Page.

Is available any links, notes or 开发者_JS百科samples?

Help me. Thanks in advance.


In doPost or doGet method in your servlet, first get Session object and call setMaxInactiveInterval() method on Session. You can similarly get session object & set max inactive interval (by calling setMaxInactiveInterval() method) from your JSP page.

Below is servlet example:

    // Get the current session object, create one if necessary
    HttpSession session = req.getSession();
    // Set the timeout
    session.setMaxInactiveInterval(2*60*60);  // two hours

You can find similar and more examples related to Servlet and sessions here :http://www.java2s.com/Tutorial/Java/0400__Servlet/ServletSessionMaxInactiveInterval.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜