• 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

SessionAware and nullPointerException

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i've always used the session aware interface without problem, but at this moment i've a strange issue.
I've created a class named CheckLogin



but when the code arrives to sessionMap.put(something...) it retrieves me NullPointerException.
Why? I've used the same syntax in other classes and it always worked fine
 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One fact, the class is invoked externally from an Action..
In other words in the action UserAction i've wrote

checkLogin cl=new checkLogin();
cl.loggedUserIsAdmin()

So my doubt is: the session aware is only supported from jsp->Actions and viceversa ? It's not possible to retrieve sessions information in a generic java class?
 
Rancher
Posts: 175
Clojure Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you instantiate the class directly rather than redirecting to it through the framework, the lifecycle events provided by the framework have no opportunity to occur. (If you bypass the interceptors in this way, what will invoke your setter?) As a result, the session map is null when you attempt to call a method on it.

Try redirecting to the other action or, better yet, keeping interrelated methods together in a single cohesive action or service class.

 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Byron wrote:

Try redirecting to the other action or, better yet, keeping interrelated methods together in a single cohesive action or service class.


Plese can you explain me how?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You and I have discussed this topic before. I gave you links and everything.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic