How to get session of http client from HttpServletRequest
If you need to use sessions, you can create a session or get an existing session using the method HttpSession getSession() of the HttpServletRequest object.
If you need to get a session if it already exists and not create one , then use the method HttpSesison getSession(boolean) with argument as false as shown in the example below.
If you need to get a session if it already exists and not create one , then use the method HttpSesison getSession(boolean) with argument as false as shown in the example below.
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { HttpSession session = req.getSession(); HttpSession existingSession = req.getSession(false); }