testing servlets that reference jsps

Patrick <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
hi all -

I have a servlet that looks like this:
--
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException {

  // dispatch request to the appropriate view
  ServletContext context = getServletContext();
  RequestDispatcher dispatch = context.getRequestDispatcher("/my.jsp");
  if (dispatch != null) {
    dispatch.forward(req, res);
  } else {
    res.setStatus(HttpServletResponse.SC_NOT_FOUND);
  }
}
---

My servlet test code looks like this:

--
ServletRunner sr = new ServletRunner();
sr.registerServlet( "myservlet", MyServlet.class.getName());


ServletUnitClient sc = sr.newClient();
WebRequest request   = new GetMethodWebRequest(
      "http://test.meterware.com/myservlet" );

request.setParameter( "myparam", "foo" );

WebResponse response = sc.getResponse( request );
--

When I run the test I get this error:

com.meterware.httpunit.HttpNotFoundException: Error on HTTP request: 404
/myjsp.jsp [http://test.meterware.com/myservlet?myparam=foo]
    at com.meterware.httpunit.WebClient.validateHeaders(WebClient.java:575)
    at com.meterware.httpunit.WebClient.updateClient(WebClient.java:464)
    ....

How can I specify the root path of the jsp so that the ServletRunner can
know how to locate the JSP?

Thanks

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.