JSP container provides for each JSP page, implicit variables, you can you in code. One of these variables is session. In order to get session, JSP container calls sesion = request.getSession(), before jsp is started to be executed.
This is fragment of translated jsp page. The attached code is placed before acutal JSP code
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
.....