Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Session Attribute value Ertatic 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 » Servlets
Bookmark "Session Attribute value Ertatic" Watch "Session Attribute value Ertatic" New topic
Author

Session Attribute value Ertatic

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I have a JSP that acts as a logon page. It requests a servlet(jQuery). That servlet calls a class that returns a user default value. Then the value is set to a session attribute. Now, I click a link on the same JSP to request another servlet(jQuery) using the attribute value as "${myAttribute}".

Sometimes all is well but then at times my request fails because the attribute value is blank.

The only way I can get it to consistantly work is to bring the default value back as a parameter in my jQuery call.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
"blank" or null?

That servlet calls a class that returns a user default value.


Suspicion immediatly falls on this "class" - is that really a static method or is there a class instance?

Bill
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
From my doGet of the servlet I have:



My Class:

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Still need some help with this.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
IF - attributes occasionally show up blank - ie empty string
THEN - there must be a path through your code that fails before the initialized value of "" gets set to another value

I would look for Exceptions that are not correctly reported.

Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Session Attribute value Ertatic
 
Similar Threads
HFSJ question on session attribute
how to access request attribute using EL
Quick question on session attributes
Confused about getSession
get disabled values from HttpServletRequest parameter