• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session.isNew() always true in tomcat3.3  RSS feed

 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is that I can't maintain a session over more than one page. I create a session in validateLogin.jsp:
isAdmin = customerProfileBean.isUserAdmin(username);

session.setAttribute("userType",isAdmin);
System.out.println("User Type is "+isAdmin+" in validateLogin");
session.setAttribute("user",username);
System.out.println("Max Inactive Interval is: "+session.getMaxInactiveInterval());
System.out.println("Session.isNew() is "+session.isNew()+" in validate");
System.out.println("Session.getId() is "+session.getId()+" in validate");
Then I re-direct to myLucidity.jsp, and try to access the session:
String user = null;
user = (String)session.getAttribute("user");
System.out.println("User is "+user+" in myLucidity");
System.out.println("Session.isNew() is "+session.isNew()+" in myLucidity");
System.out.println("Session.getId() is "+session.getId()+" in myLucidity");

session.isNew() is "true" in both cases, and session.getId() returns different values. Why is this happening?
I have checked the max inactive interval and it's 1800, so that's not the problem.
Can anyone help?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the two pages are in different "web applications" they won't be able to share a session.
If you really are redirecting, the cookie created by the first page will not be saved by the browser. The first page will have to generate HTML seen by the browser in order for it to save the cookie with the session ID.
Bill
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed my code to send the values in the redirect URL and then only use sessions after that.
I still get the null pointer exception in the other JSPs, where session attributes are attmpted to be accessed, and the sessionId still varies from JSP to JSP, even when the link between them is a href anchor rather than a re-direct.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are all of these JSP in the same "web application"? Does the browser you are using hae cookies enabled?
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!