I'm new to
JSP and am trying to get my first project up an running. I thought I'd start with two basic pages: login.jsp and index.jsp. I wanted to write a scriptlet for the head of index.jsp that would redirect to login if the user was not already logged in. I wrote the following code:
This works just fine for the purpose of redirecting the user . After the above scriptlet, I can print the session suerID and password on the index.jsp page without a problem:
Your user name is: <%= session.getAttribute("UID") %> <br>
Your password is: <%= session.getAttribute("password") %>
The problem is that as soon as I leave the index.jsp page, the next page doesn't find session values for UID or password. Is there something I have to do to get these session variables to persist across multiple jsps? I thought that the calls to session.setAttribute() wuld be enough?