tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: custom class as resource
Date Mon, 31 Jan 2011 22:13:09 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexis,

On 1/31/2011 4:48 PM, alexis wrote:
> The only difference i found is the class that sets the attribute on
> the servletcontext extends ServletContextListener.
> 
> the class that access and reads the context extends HttpServlet and
> shows the content upon an http request.
> 
> the class that gets the null pointer, also extends HttpServlet but
> it's instantiated from another class and a method is called from
> there.

Can you show us the code?

If you aren't calling YourNewServlet.init(ServletContext) then you will
probably get NPEs. Tomcat provides lots of bootstrap services for
servlets that you will have to provide yourself if you want to load,
instantiate, and configure servlets yourself.

> there's no http request on this class. i've also declared this
> class as a servlet in the web.xml of my app.

That may not matter, depending on what your code it doing. Tomcat is
likely to create an Servlet instance that you cannot access, and you're
just wasting memory.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1HM/UACgkQ9CaO5/Lv0PA3oACeLT8bjyT2BY4w5Rq/DCTI3ghN
VqgAn3HryldcUCRxrBIHQrKhXkwdDhRs
=7JfY
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message