I was missing the 
   super.init(config);
in the Servlet init(ServletConfig config) procedure.

After putting this in the getServletContext is working.

Thanks,

-----Original Message-----
From: sam d [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 06, 2001 8:59 AM
To: JRun-Talk
Subject: Re: getServletContext exception


I was also getting the same error. when I got 
servlet context in the init() method and saved a
reference in variable it works.

This may not be the correct approach. Hope this helps.

Thanks.

--- Ravi Vedire <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I am trying to get the ServletContext in the my
> Servlet and I am getting the
> following exception. 
> 
> Without the ServletContext the code is working fine.
> 
> Hear is what I am trying to accomplish.
> 
> As of now after processing the request I am doing a
> response.sendRedirect to
> let the JSP to handle the presentation of the HTML.
> 
> But I would like to reduce that round trip and be
> able to directly call or
> forward the request to the JSP.
> 
> In order to do it I did the following
>         String url = "/jsp/TestProj/Test.jsp";
>         ServletContext sc = getServletContext();
>         RequestDispatcher rd =
> sc.getRequestDispatcher(url);
>         rd.forward(request,response);
> 
> But when my it try's to execute the
> getServletContext call I get the
> following exception. Any Ideas?
> 
> Thanks,
> Ravi
> 
> java.lang.NullPointerException
>       at
>
javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
>       at
>
com.dpd.servlet.NavigationServlet.service(NavigationServlet.java:290)
>       at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
>
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1417)
>       at
>
allaire.jrun.session.JRunSessionService.service(../session/JRunSessionServic
> e.java:1082)
>       at
>
allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1271)
>       at
>
allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatc
> her.java:39)
>       at
>
allaire.jrun.servlet.Invoker.service(../servlet/Invoker.java:84)
>       at
>
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1417)
>       at
>
allaire.jrun.session.JRunSessionService.service(../session/JRunSessionServic
> e.java:1082)
>       at
>
allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1271)
>       at
>
allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDis
> patcher.java:89)
>       at
>
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1553)
>       at
>
allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1543)
>       at
>
allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
>       at
>
allaire.jrun.jrpp.ProxyEndpoint.run(../jrpp/ProxyEndpoint.java:388)
>       at
> allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to