• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem using getSession(boolean create)

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Java API docs say : If create is false and the request has no valid HttpSession, this method returns null.

one.jsp



[bold]two.jsp [/bold]




I click at hyperline two in one.jsp after the session is expired (2 minutes in this case). When the control goes to two.jsp, it creates a new session, but since the session has expired, i should get null(according to API docs) and not new session object.
[ June 21, 2006: Message edited by: Marc Peabody ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to close your other threads related to this very problem. Please try to keep all questions related to a single problem in a single thread.

LOOK HERE!
********************
JSPs create a new session by default. If you want your second JSP to not automatically create a new session you must specify this directive in the second JSP:
<%@ page session="false">

********************
[ June 21, 2006: Message edited by: Marc Peabody ]
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i want to do the same thing in servlets, then how i can do it!!!.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlets do not create a session by default. There are no special directives or other tricks necessary to make the same thing work in a servlet. I'm assuming that's what you're asking.
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes thats true, but the problem i am facing is that once my session is expiring sessionDestroyed(HttpSessionEvent sessionEvent) of HttpSessionListener is called. Now the user is not aware that the session has expired or not... if he clicks at any of the hyperlinks (after the session is expired), then i have to check whether the session is expired. I do it by using request.getSession(false) to redirect him to sessionExpired.jsp. But the problem is request.getSession(false) creates a new session for the same user (Browser, the sessionID of new session is different from first one). So i have no way to know that the session has expired .......to take appropriate action
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by N Chaurasia:
But the problem is request.getSession(false) creates a new session for the same user


NO, IT DOESN'T!

I believe you are ignoring my posts. I've explained how it works. Please read them again.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And reread the Naming Policy too
http://www.javaranch.com/name.jsp
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for helping Satou, but as there are at least 38 people with the surname Chaurasia in the New York state alone (picking a state at random), it is quite possibly N Chaurasia's real name. And we do allow initials for the first letter.

Regards, Andrew
 
get schwifty. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic