It is called from servlet/JSP's but I want the class to be independent of that. i.e the class should be able to query something and get the servlet context
Exactly what do you need from the servlet context? Perhaps there is a better way to get it.
It seems to me your requirements are incompatible - time for a redesign maybe. If you can make the class independent of the servlet environment, it will be easier to
test.
Bill