• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Attribute Property Returns Null

 
Ranch Hand
Posts: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot figure out how this last line of this code fragment could return null.
I am checking for the validity of the session so this line of code should never be reached.

 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The session may be "valid" but your problem is that the valid session doesn't include an attribute named "QMSSessionParmsObj". So line 15 assigns null to the dft variable.

It may be that lines 14 to 16 all assign null to those variables because the session attributes don't exist, but your line 31 is the first place where the code tries to use any of them.
 
Steve Dyke
Ranch Hand
Posts: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:The session may be "valid" but your problem is that the valid session doesn't include an attribute named "QMSSessionParmsObj". So line 15 assigns null to the dft variable.

It may be that lines 14 to 16 all assign null to those variables because the session attributes don't exist, but your line 31 is the first place where the code tries to use any of them.



So since I assign these attributes when the session gets instantiated, I either have a request.getSession() called without the false parameter or I am removing the assigned attributes.
 
Marshal
Posts: 4510
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While I don't see how it could be a problem in the code that you posted, you do actually call getSession() without specifying setting the create parameter to false.

Maybeinstead of
To debug, why not call the HttpSession#getAttributeNames method and iterate/log all the attribute names.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic