You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Troy Gould <tr...@dooyoo.co.uk> on 2001/11/21 23:00:38 UTC

problem with requestDispatcher.include(...) ?

I'm trying to test a Servlet which includes a jsp file in it's response.
The servlet itself, prints out nothing.
For some reason, when running under cactus, the jsp file's output never
ends up in the WebResponse.getText() data.
I'm using the following within my servlet:
context.getRequestDispatcher(myJSPFileToInclude).include(request,
response)


Not sure why this is happening.  The jsp include from my servlet works
fine normally, but in cactus it fails to work at all.

Cactus is also completely fine if my servlet is returning text instead
of including the jsp.

My JSP looks like the following:

<%@page import="javax.servlet.http.Cookie" %>


<HTML>
<HEAD>
<TITLE>Cactus framework dummy JSP</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<br>
<br>
<%
            Cookie cookies[] = request.getCookies();
            for (int i = 0 ; i < cookies.length; i++) {
                out.println("Cookie Name: " + cookies[i].getName() + "
Value: " + cookies[i].getValue());
                System.out.println("Cookie Name: " +
cookies[i].getName() + " Value: " + cookies[i].getValue());
            }
%>
</BODY>
</HTML>




Servlet contains the following as the test.  All I'm trying to do is
make sure that my login servlet is putting the sessionID into a cookie.
I've got a lot of extra garbage in the tester as I've been trying to
figure out why that jsp data isn't showing up.  This is also causing a
problem in that the response object seems to contain nothing.. I get
exceptions like NoSuchMethodExists if I attempt to even make the simple
call of webResponse.getCookies().


    /**
     * Initialise the request parameters.
     * <p>
     * <b>Note:</b> this method is executed on the client side.
     */
    public void beginLogin(WebRequest webRequest) {
        if (log.isDebugEnabled())
            log.debug("beginViewBalance():: BEGIN");

        // set up the HTTP parameters
        servletPath = "/login";

        queryString = "NAME=test21&PASSWORD=test21&action=login";

	  request.setURL("localhost:7001", "/Aurora", servletPath, "",
queryString);

        if (log.isDebugEnabled())
            log.debug("beginViewBalance():: END");
    }

    public void testLogin() throws IOException, ServletException {
        try {
            if (log.isDebugEnabled())
                log.debug("testViewBalance():: BEGIN");

            UserLoginServlet servlet = new UserLoginServlet();
            servlet.init(config);

            servlet.doGet(request, response);

            if (log.isDebugEnabled())
                log.debug("testViewBalance():: END");
        }
        catch (IOException ex) {
            throw ex;
        }
        catch (ServletException ex) {
            throw ex;
        }
        catch (Exception ex) {
            log.error(ex.getMessage(), ex);
		assert(ex.getMessage(), false);
        }
    }

    /**
     * Check the response.
     * <p>
     * <b>Note:</b> this method is executed on the client side.
     *
     * @param webRresponse the response from the server
     */
    public void endLogin(org.apache.cactus.WebResponse webResponse) {

        try {
            if (log.isDebugEnabled())
                log.debug("endLogin():: BEGIN");

            if (log.isDebugEnabled()) {
                log.debug("Get cookies");
                for (int i = 0 ; i < cookies.length; i++) {
                    log.debug("Cookie Name: " + cookies[i].getName() + "
Value: " + cookies[i].getValue());
			  
                }
            }

            assertNotNull(webResponse.getText());
            log.info(webResponse.getText());

            if (log.isDebugEnabled())
                log.debug("endLogin():: END");
        }
        catch (Exception ex) {
            log.error(ex.getMessage(), ex);
		assert(ex.getMessage(), false);
        }
    }



Any help on why I can't include or forward to a jsp file would really be
appreciated.  
Thanks!

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>