Search code examples
javahttpsession

Java HttpSession


Is HttpSession in java servlet is created only after

HttpSession s = request.getSession();

?

In my code I didn't write that, but when I use if (request.getSession(false) == null) ..., it doesn't work. Why?


Solution

  • A HttpSession is created when calling request.getSession().

    But if you access a JSP by default it will automatically create a session.This behaviour can be disabled by using: <%@ page session="false">

    Are you using JSP?