wood burning stoves 2.0*
The moose likes JSP and the fly likes Session variables are not getting storred Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Session variables are not getting storred" Watch "Session variables are not getting storred" New topic
Author

Session variables are not getting storred

vishnu vyasan
Ranch Hand

Joined: May 27, 2008
Posts: 39
Hello all,

I am using oc4j for application development. in my jsp page i am setting some variables in to session but immedietly retriving the values
in same page itself, i am getting it as null.



The first SOP prints the value.
The second SOP command prints null.

The same code is working fine in Tomcat. Is this the problem with the App server? in that case any body knows what to do in OC4J to activate the session?

Thanks in advance
Vishnu
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

Are you declaring session like



And fetching session values like



Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

System.out.println(session.getAttribute(crcpr));


"crcpr" . notice your getAttribute argument
vishnu vyasan
Ranch Hand

Joined: May 27, 2008
Posts: 39
Do we need to declare the session like this in jsp?



by adding this my compiler returns an error

Error(7,41): variable session is already defined in method _jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)


ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

HttpSession that is "session" is available directly for use in jsp as session is an implicit object.

In your jsp scriptlet write

vishnu vyasan
Ranch Hand

Joined: May 27, 2008
Posts: 39
Hi

Now i am able to print the values retrived from session on the same page.

But when i move to next page and try to get the variable from session the values of all variables are null.

Any idea why this is happening? i have set the session.setMaxInactiveInterval(600);

Thanks & Regards
Vishnu
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

The default session time out with tomcat is 30 minutes.

Since you are using session.setMaxInactiveInterval(600)

It will time out session after 600 seconds. Are you trying to move to next page exactly after 600 seconds ? ..., try increasing the value in seconds.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session variables are not getting storred
 
Similar Threads
Display table row value in another form
Doubt in try and finally block execution.
Null Pointer Exception
jsp to actionhadler
NullPointerException?????