• Post Reply Bookmark Topic Watch Topic
  • New Topic

session object gives 'null' in the next JSP page

 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two jsp pages. In the first jsp page i am setting the session something like this:
session.setAttribute("key","value");
When i use getAttribute() method for this key in the same page, i am getting the value properly.

I have a submit button in the jsp and it sends to another jsp.
When i use getAttribute() method for the same key, i get the value as null.

P.S.: getId() method returns different value in both these JSPs. I dont know the reason or impact. (Also not using any absolute address for directing)

Kindly help in this. Thanks in advance!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
welcome to javaranch . coming to your question setting object [or something] into session should be done on servlet,please dont use jsp for this. can you post your jsps [please use code tag to post your code]
 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working that on remote login. I cant paste the code from there for some reasons . I am not using any servlet in that. Just for a testing utility i have those jsps.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well,that is Ok. Are attributes name same ? . please give some more information
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well,that is Ok. Are attributes name same ? . please give some more information
[needs to be delete please]
 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. attribute names are same only. I checked more than 20 times
 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly i have only these things in jsp. I have nothing more (just for testing purpose, i am just trying to get attribute and print)
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please check if you have not given value "false" for page directive attribute "session".
Also let us know the environment and how you are going to next JSP on submit button?

 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page directive is not setting false to session anywhere. I am using RAD. The server is customized to some standards. Not the direct websphere server.
 
Albareto McKenzie
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This could sound stupid but are you getting the parameter in the next jsp from the session object and not from the request or pageContext?
 
vignesh manohar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session is one of the implicit objects in jsp. So it should normally work fine unless different session is created for the other jsp. I also tried getting the session from the request's parameter, as we will get in servlet. It wasn't fruitful either. I see that different session is created in the next jsp as the session id is looking different in the jsps. I have no clue why...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!