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!!!
Sean <br />SCJP2, SCJP2p1.4, SCWCD
Satish Kasala
Greenhorn
Joined: Dec 19, 2000
Posts: 16
posted
0
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
maha anna
Ranch Hand
Joined: Jan 31, 2000
Posts: 1467
posted
0
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
Joined: Oct 24, 2000
Posts: 115
posted
0
Thanks both of you. Especially Maha, you pinpointed the cause of my problem.. Thanks guys!!!