In JSP, session can be used directly, but if you want to use session object to store attributes or other operations in servlet, you need to create a session object first. The code is as follows
HttpSession session = request.getSession();
can be used directly