com.diasparsoftware.javax.servlet
Class ForwardingServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.diasparsoftware.javax.servlet.ForwardingServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ForwardingServlet
extends javax.servlet.http.HttpServlet

A servlet that forwards to the location you specify. Use this in conjunction with ServletUnit (http://httpunit.sourceforge.net) to test page templates, such as JSPs. Sample use.

 servletRunner = new ServletRunner(
     getWebContentPath("/WEB-INF/web.xml"),
 
 servletRunner.registerServlet("/forward",
     ForwardingServlet.class.getName());
 
 client = servletRunner.newClient();
 
 ForwardingServlet servlet =
     (ForwardingServlet) invocationContext.getServlet();
 
 servlet.setForwardUri("/shopcart.jsp");
 
 HttpServletRequest request = invocationContext.getRequest();
 request.setAttribute("shopcartDisplay", shopcartBean);
 
 servlet.service(
     invocationContext.getRequest(),
     invocationContext.getResponse());
 
 WebResponse response =
     invocationContext.getServletResponse();
 
 assertEquals("....", response.getText());
 

Version:
$Revision: 1.1 $
Author:
Serialized Form

Constructor Summary
ForwardingServlet()
           
 
Method Summary
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 java.lang.String getForwardUri()
           
protected  void handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void setForwardUri(java.lang.String forwardUri)
          The URI to which this servlet ought to forward when you invoke service().
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardingServlet

public ForwardingServlet()
Method Detail

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

setForwardUri

public void setForwardUri(java.lang.String forwardUri)
The URI to which this servlet ought to forward when you invoke service().

Parameters:
forwardUri -

getForwardUri

public java.lang.String getForwardUri()


Copyright © 2003-2004 Diaspar Software Services, Inc.. All Rights Reserved.