This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have two servlets, and 1 bean. In one servlet i set the values of the bean and store them in the servlet context. In another servlet i try to get the ServletContext back, But it allways returns a null pointer error...
Here is the code, thanks in advance for help.
And finally the bean
If you got this far, thanks for looking [ December 24, 2005: Message edited by: Bear Bibeault ]
1. are both servlets in the same "Web application"? are both defined in one web.xml? 2. you left out one crucial bit of information - which reference is null? is it bob? if so maybe your init method is at fault and you are missing the ServletConfig reference is it dbParam? if so maybe the two servlets are not really sharing the same context 3. are you relying on the "invoker" servlet at any point? See this Ranch FAQ if you are. Bill
Joined: Dec 12, 2005
well ive kinda sorted the problem now using instance rather that servlet context to store it...
However i would like to switch back to servlet context as my tutor seems to prefer this
Bob is the place where it throws a null reference back at me, They are both in one web application, i havnt used any init meathods so not sure how that can be the case. Its really got me stumped, ohh and no invoker meathod either...
Thanks for looking! [ December 24, 2005: Message edited by: Al Hollis ]
Bob is the place where it throws a null reference back at me
This is rather ambiguous. Are you saying that the variable "bob" contains null? Surely not. Why don't you tell us which line of code throws the exception? Your stack trace should tell you the exact line number.