• 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

getServletContext() returning null ???

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
My servlet has the following code in its doGet() method.
String adr = "/xxx/xxx.jsp";
ServletConfig sConf = getServletConfig(); // line1
ServletContext sCont = sConf.getServletContext(); //line2
RequestDispatcher dispatcher= sCont.getRequestDispatcher(adr);//line3
line 1 seems to work fine. (I originally had print statement between each line.. )
but line2 returns null..
'cos I get NullPointerException at line 3.
I am don't know what is wrong...
HELP!!!
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sean,
Can you be more specific about the servlet engine you are using. Some servlet engine doesn't seem to implement the JSDK specs completed. getServletContext() is one of the methods that is primarily based on the servlet engine.
Satish
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sean,
If we had overridden init(ServletConfig config)throws .. {...} method, then we shouldn't forget to call super.init(config); If we miss this line, then latter our servlet can't get hold of ServletConfig object and we will get NullPointerException. Is this your case?
regds
maha anna
[This message has been edited by maha anna (edited December 21, 2000).]
 
sean cee
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks both of you.
Especially Maha, you pinpointed the cause of my problem..
Thanks guys!!!
 
get schwifty. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic