HTTPUnit does not find JSP pages

Posted on 2006-03-28
Last Modified: 2008-01-09
In my HttpServlet I redirect the request using the following:
request.getRequestDispatcher("/testpage.jsp").forward(request, response);

Then in my HTTPUnit TestCase I have the following:
public void testGet() throws Exception
        ServletRunner sr = new ServletRunner(new File(
        ServletUnitClient client = sr.newClient();

        WebResponse response = client

The tests works fine until it reaches the request redirection line in my servlet. It then fails with the following error:
com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 org.apache.jasper.JasperException: C:\Documents and Settings\shahla\MyWorkspace\MyProject\WEB-INF\web.xml (The system cannot find the path specified) [http://localhost:8080/MyRecord?username=tester]
      at com.meterware.servletunit.ServletUnitClient.newResponse(
      at com.meterware.httpunit.WebWindow.getResource(
      at com.meterware.httpunit.WebWindow.getSubframeResponse(
      at com.meterware.httpunit.WebWindow.getResponse(
      at com.meterware.httpunit.WebWindow.getResponse(
      at com.meterware.httpunit.WebClient.getResponse(
      at test.LoadRecordTest.testGet(
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      at java.lang.reflect.Method.invoke(
      at junit.framework.TestCase.runTest(
      at junit.framework.TestCase.runBare(
      at junit.framework.TestResult$1.protect(
      at junit.framework.TestResult.runProtected(
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

My web.xml has the following:

The test passes when I commented out the line that redirects the request. Do I have to do something special to allow ServletUnitClient in HTTPUnit to follow redirections? Autoredirect is already set to true.

Any help is greatly appreciated.
Question by:salmasri
    1 Comment
    LVL 29

    Accepted Solution

    It's not a redirection but an internal forward. A redirection invovles a response being send to the browser saying that the content has temporarily moved -  HTTP code 307.
    Because the servlet does not actually do the response, I think you need to implement what is shown here in the section entitled "Testing Servlet Internals"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now