• Post Reply Bookmark Topic Watch Topic
  • New Topic

each time iam creating a new session  RSS feed

 
shekar krishna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppl,

I want to reuse the existing session. I am saying req.getsession()in my code. But each time, it is creating a new one. How to reuse the existing session.

I tried req.getsession() but it is not working fine.

plz suggest.

Thanks,
chandra
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shekar krishna:
I want to reuse the existing session. I am saying req.getsession()in my code. But each time, it is creating a new one. How to reuse the existing session.


How do you know that??
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are maintained by container. They are resued by default. Unless and untill that particular session is closed abruptly by closing the browser instance(or)server crash, user is in the same session.
 
shekar krishna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adeel,

I came to know by printing the session object.

It prints something like weblogic.blah.blah.blah@somenumber.
It prints differnt number if u refresh the browser.

Plz suggest.

Thanks,
Chandra
 
Manoj Kumkumath
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try getting the Session by method
request.getSession(false).

This will return you a session only if there is an existing session and null if not.
 
Thibault Dangr�aux
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you test that, do you have cookies enabled? If cookies are not enabled, the server will not be able to track session accross pages, unless you take special steps (URL rewriting et response.encodeUrl).
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thibault Dangr�aux:
When you test that, do you have cookies enabled?


Check this out, Shekar.
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a servlet or a jsp the one giving you troubles?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!