• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session.isNew() always true in tomcat3.3

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic