Just out of curiosity, why are you re-putting the value into the session on
subsequent pages? Are you allowing the users to change the value after its
original entry? If not, drop the putValue after the 1st instance. Your
code does not appear to initialize foo; so it defaults to null. If for any
reason, your getValue fails, then the putValue will have a null pointer.
Also, its obvious, but double check that all pages reference the value names
with the same alpha-case.
Incidentially, here's a code snippet to do what Arni suggests, embed it in
the page for debugging purposes:
<% String[] keys = session.getValueNames();
for ( int n = 0; keys != null && n < keys.length; n++ )
{
%>
Session property <%= n %> is <%= session.getValue(keys[n]) %>.
<%
}
%>
-----Original Message-----
From: Arni Raghu
To: [EMAIL PROTECTED]
Sent: 2/29/00 9:48 PM
Subject: Re: problem with sessions and jsp
Try using session.getNameValues() or getValueNames() ( I always forget
which
one!) that should return u a list of all the session variables. Use this
to
debug and see exactly at what page u lose the session variables..might
help
in debugging..other thing is increasing the session timeout
values..increase
it just in case though I am not sure it will help..
hth,
A
> i am creating a web app that uses a servlet to login and then passes
the
> user along to an initial jsp and several sub-jsps below that. once i
> authenticate the user in the servlet i store their info (userid,
logintime)
> in the session object because i want to display that on all the
subsequent
> jsps.
>
> After placing the info in the session object and redirecting to the
first
> jsp i am able to extract and display that information 100% of the
time.
>
> my problem is this: any calls to subsequent jsps may or may not be
able
to
> extract the info. about 30% of the time when i try to display the
info my
> variables are null. in other words, the information is no longer
there.
> here is the code i'm using on each page. it comes before the </head>
tag:
>
> String foo
> ...
> foo = (String) session.getValue("userName"); file://get the value
> ...
> session.putValue("userName", foo); file://place back in the session
for
next
> page
> ...
>
> as i said before, this works about 60-70% of the time, and the
subsquent
> page will successfully extract 'userName' and assign it to 'foo'. but
other
> times the value isn't there and foo is null, throwing a
nullpointerexception
> when i try to put it back into the session.
>
> am i doing something completely wrong here? am i leaving something
out?
any
> help would be very welcome.
>
> bradley
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
========================================================================
===
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
========================================================================
===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets