Everytime I call the doGet() method of my servlet I get a
NullPointerException - it seems that the servlet has no context (i.e. no
ServletConfig), and the call to getServletContext() fails.
As my code relies on the following line, this is a problem:
getServletContext().getRequestDispatcher(jspURL).forward(request, response);
Is there a workaround or, as is quite possible, am I just being immensely
stupid?
======================================================================
The test code:
public void beginDoGet(ServletTestRequest theRequest) throws Exception
{
theRequest.setMethod(ServletTestRequest.GET_METHOD);
theRequest.setURL("http://pc_ojcheesman:8080", "/sinfo",
"/CentralLoggingServlet", "", testQueryString);
}
public void testDoGet() throws Exception
{
CentralLoggingServlet servlet = new CentralLoggingServlet();
servlet.doGet(request, response);
}
public void endDoGet(HttpURLConnection theConnection) throws Exception
{
assertEquals("<html><body>Error msg received:" + testQueryString +
"</body></html>",
AssertUtils.getResponseAsString(theConnection));
}
======================================================================
(The servlet works fine if called normally via a browser)
Jim
--
* Jim Cheesman *
Trabajo: [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
Personal: [EMAIL PROTECTED] (34) 606 770 244
Practice safe eating -- always use condiments.