A better way to handle this stuff is to just get the servlet context
when you need it and not store it in the request.  If you have access to
the request, you have access to the servlet context.

ie ServletContext servContext = request.getSession().getServletContext() ;

--David

Marten Lehmann wrote:

> Hello,
>
> within the init() of a filter, I'm storing a reference to the
> servletContext:
>
> filterConfig.getServletContext().setAttribute("servletContext",
> filterConfig.getServletContext());
>
> But when I'm trying to access this attribute in the doFilter-method, I
> get a NullPointerException:
>
> ServletContext servletContext = (ServletContext)
> request.getAttribute("servletContext");
>
> Why doesn't this work?
>
> Regards
> Marten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
=======================================
David Smith
Network Operations Supervisor
Department of Entomology
College of Agriculture & Life Sciences
Cornell University
2132 Comstock Hall
Ithaca, NY  14853
Phone: 607.255.9571
Fax: 607.255.0939



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to