javax.servlet.http.HttpSession.getMaxInactiveInterval()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(291)

本文整理了Java中javax.servlet.http.HttpSession.getMaxInactiveInterval()方法的一些代码示例,展示了HttpSession.getMaxInactiveInterval()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpSession.getMaxInactiveInterval()方法的具体详情如下:
包路径:javax.servlet.http.HttpSession
类名称:HttpSession
方法名:getMaxInactiveInterval

HttpSession.getMaxInactiveInterval介绍

[英]Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method.

A return value of zero or less indicates that the session will never timeout.
[中]返回servlet容器在客户端访问之间保持此会话打开的最大时间间隔(秒)。在此间隔之后,servlet容器将使会话无效。可以使用setMaxInactiveInterval方法设置最大时间间隔。
返回值为零或更小表示会话永远不会超时。

代码示例

代码示例来源:origin: perwendel/spark

/**
 * @return the maximum time interval, in seconds, that the container
 * will keep this session open between client accesses.
 */
public int maxInactiveInterval() {
  return session.getMaxInactiveInterval();
}

代码示例来源:origin: jfinal/jfinal

public int getMaxInactiveInterval() {
  return session.getMaxInactiveInterval();
}

代码示例来源:origin: jfinal/jfinal

public int getMaxInactiveInterval() {
  return session.getMaxInactiveInterval();
}

代码示例来源:origin: Atmosphere/atmosphere

private static SessionTimeoutRestorer getOrCreate(AtmosphereConfig config, HttpSession s) {
  SessionTimeoutRestorer restorer = (SessionTimeoutRestorer) s.getAttribute(KEY);
  if (restorer == null) {
    restorer = new SessionTimeoutRestorer(config, s.getMaxInactiveInterval());
    s.setAttribute(KEY, restorer);
  }
  return restorer;
}

代码示例来源:origin: apache/shiro

public long getTimeout() throws InvalidSessionException {
  try {
    return httpSession.getMaxInactiveInterval() * 1000L;
  } catch (Exception e) {
    throw new InvalidSessionException(e);
  }
}

代码示例来源:origin: hs-web/hsweb-framework

int timeout = request.getSession().getMaxInactiveInterval() * 1000;

代码示例来源:origin: Atmosphere/atmosphere

public FakeHttpSession(HttpSession session) {
  this(session.getId(), session.getServletContext(), session.getLastAccessedTime(), session.getMaxInactiveInterval());
  copyAttributes(session);
}

代码示例来源:origin: apache/ignite

/**
 * @param id Session ID.
 * @param ses Session.
 */
WebSession(String id, HttpSession ses) {
  assert id != null;
  assert ses != null;
  this.id = id;
  createTime = ses.getCreationTime();
  accessTime = ses.getLastAccessedTime();
  maxInactiveInterval = ses.getMaxInactiveInterval();
  isNew = ses.isNew();
  attrs = new HashMap<>();
  Enumeration<String> names = ses.getAttributeNames();
  while (names.hasMoreElements()) {
    String name = names.nextElement();
    attrs.put(name, ses.getAttribute(name));
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

@RequestMapping(value = "/sessionTimerReset", method = RequestMethod.GET)
public @ResponseBody String sessionTimerReset(HttpServletRequest request,
    HttpServletResponse response) throws Exception {
  long serverSessionTimeoutInterval = request.getSession().getMaxInactiveInterval() * 1000;
  return (new JsonResponse(response))
      .with("serverSessionTimeoutInterval", serverSessionTimeoutInterval)
      .done();
}

代码示例来源:origin: spring-projects/spring-session

@Override
  public void doFilter(HttpServletRequest wrappedRequest) {
    int interval = wrappedRequest.getSession().getMaxInactiveInterval();
    // 30 minute default (same as
    // Tomcat)
    assertThat(interval).isEqualTo(1800);
  }
});

代码示例来源:origin: spring-projects/spring-session

@Override
  public void doFilter(HttpServletRequest wrappedRequest) {
    assertThat(wrappedRequest.getSession().getMaxInactiveInterval())
        .isEqualTo(interval);
  }
});

代码示例来源:origin: apache/ignite

ses.getMaxInactiveInterval());

代码示例来源:origin: spring-projects/spring-session

@Override
  public void doFilter(HttpServletRequest wrappedRequest) {
    wrappedRequest.getSession().setMaxInactiveInterval(interval);
    assertThat(wrappedRequest.getSession().getMaxInactiveInterval())
        .isEqualTo(interval);
  }
});

代码示例来源:origin: hs-web/hsweb-framework

String sessionId = session.getId();
UserToken token = userTokenManager.getByToken(sessionId);
long interval = session.getMaxInactiveInterval();

代码示例来源:origin: spring-projects/spring-session

@Override
  public void doFilter(HttpServletRequest wrappedRequest) {
    HttpSession session = wrappedRequest.getSession();
    session.invalidate();
    // no exception
    session.getMaxInactiveInterval();
    session.setMaxInactiveInterval(3600);
  }
});

代码示例来源:origin: apache/geode

@Override
public ExpirationAttributes getExpiry(Region.Entry<String, HttpSession> entry) {
 HttpSession session = entry.getValue();
 if (session != null) {
  return new ExpirationAttributes(entry.getValue().getMaxInactiveInterval(),
    ExpirationAction.DESTROY);
 } else {
  return EXPIRE_NOW;
 }
}

代码示例来源:origin: javamelody/javamelody

age = new Date(now - session.getCreationTime());
expirationDate = new Date(
    session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000L);

代码示例来源:origin: Atmosphere/atmosphere

&& req.getSession().getMaxInactiveInterval() >= 0
  && req.getSession().getMaxInactiveInterval() * 1000L < timeout) {
throw new IllegalStateException("Cannot suspend a " +
    "response longer than the session timeout. Increase the value of session-timeout in web.xml");

代码示例来源:origin: apache/ignite

updateAttributes(transformSessionId(sesId), updates, ses.getMaxInactiveInterval());

代码示例来源:origin: apache/geode

try {
 session = (GemfireHttpSession) manager.wrapSession(context,
   nativeSession.getMaxInactiveInterval());
 session.setIsNew(true);
 manager.putSession(session);

相关文章