1

I have a servlet that forwards the request/response to a JSP, but I keep getting the exception

junit.framework.AssertionFailedError: An exception has been thrown. com.meterware.httpunit.HttpNotFoundException: Error on HTTP request: 404 java.lang.ClassNotFoundException: org.apache.jasper.servlet.JspServlet [http://localhost/site-search/search-results.jsp] at junit.framework.Assert.fail(Assert.java:47)

So I tried to register the JSP to the mock web.xml that is registered into the Servlet Runner, but then I get the following exception.

org.xml.sax.SAXException: Node < servlet > has no child named < servlet-class >

It seems to me that Servlet Unit doesn't have a way to test if a servlet forwards to a specific view/JSP. Even if I try to register the JSP in the web.xml with < jsp-file > instead < servlet-class >, Servlet Unit doesn't seem to like that. All of the examples that I've seen are just simple servlets that output to the PrintWriter. Has anyone been able to successfully test a servlet that forwards/redirects to a JSP through ServletUnit?

Thanks,

Juan

jcb
  • 195
  • 1
  • 4
  • 20
  • Have you seen this [answer](http://stackoverflow.com/questions/297111/example-of-using-servletunit-to-test-jsps)? – efan Feb 25 '13 at 16:46

0 Answers0