So what I do in the init() is:
And then in another Serlvet I do the following:
When this code gets executed, I get a NullPointerException. Am I doing this right/wrong??
Yes, I am pre-loading the servlet. I have System.out command in my init method (for testing just this) and I can see it printing out when I start Tomcat before I ever access my application.
I built an "Action" class that is abstract. It looks like:
Now, originally, I was not passing the ServletConfig to the processRequest method. But now that I am and I am using:
This NullPointer error message have gone away and everything is working just fine.
Once again, I have no idea why I have to pass the ServletConfig around to get at the ServletContext.
Originally posted by Chad McGowan:
That doesn't make sense to me.
The HttpServlet getServletContext method actually returns getServletConfig().getServletContext(), so the ServletContext reference you get should be the same, regardless of how it is called.
That's what I thought, but it wasn't doing what it was supposed to be doing. At least I have a work around until I figure out what the heck is going on.