I have two JSP pages: Login.jsp and Main.jsp.
For the url pattern / I have a servlet which does this:
HttpSession session = request.getSession(false);
if (session == null) {
response.sendRedirect("Login.jsp");
} else {
response.sendRedirect("Home.jsp");
}
The two JSP pages are empty as of now.
When I browse localhost:8080/appname/ in my browser, it routes to Login.jsp as expected. But when I try to browse it for the second time, it routes to Home.jsp.
When I try to debug, session is not null and I could find a cookie with JSESSIONID in my chrome browser.
I don’t do getSession() anywhere else.
Can anyone explain me what is going on here?
Thanks.
A JSP creates a session by default. If you don’t want a session then add