Interface InvocationContext


public interface InvocationContext
An interface which represents the invocation of a servlet.
Author:
Russell Gold
  • Method Summary

    Modifier and Type
    Method
    Description
    javax.servlet.Filter
    Returns the current active filter object.
    javax.servlet.FilterChain
    Returns the current filter chain.
    Returns the target frame for the original request.
    javax.servlet.http.HttpServletRequest
    Returns the request to be processed by the servlet or filter.
    javax.servlet.http.HttpServletResponse
    Returns the response which the servlet or filter should modify during its operation.
    javax.servlet.Servlet
    Returns the selected servlet, initialized to provide access to sessions and servlet context information.
    Returns the final response from the servlet.
    boolean
    Returns true if the current context is a filter, rather than a servlet.
    void
    Removes the top request dispatcher or filter from this context.
    void
    pushFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
    Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet.
    void
    pushForwardRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Adds a request dispatcher to this context to simulate a forward request.
    void
    pushIncludeRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Adds a request dispatcher to this context to simulate an include request.
    void
    Invokes the current servlet or filter.
  • Method Details

    • getRequest

      javax.servlet.http.HttpServletRequest getRequest()
      Returns the request to be processed by the servlet or filter.
    • getResponse

      javax.servlet.http.HttpServletResponse getResponse()
      Returns the response which the servlet or filter should modify during its operation.
    • service

      void service() throws javax.servlet.ServletException, IOException
      Invokes the current servlet or filter.
      Throws:
      javax.servlet.ServletException
      IOException
      Since:
      1.6
    • getServlet

      javax.servlet.Servlet getServlet() throws javax.servlet.ServletException
      Returns the selected servlet, initialized to provide access to sessions and servlet context information. Only valid to call if isFilterActive() returns false.
      Throws:
      javax.servlet.ServletException
    • getServletResponse

      WebResponse getServletResponse() throws IOException
      Returns the final response from the servlet. Note that this method should only be invoked after all processing has been done to the servlet response.
      Throws:
      IOException
    • getFrame

      FrameSelector getFrame()
      Returns the target frame for the original request.
      Since:
      1.6
    • pushIncludeRequest

      void pushIncludeRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
      Adds a request dispatcher to this context to simulate an include request.
      Throws:
      javax.servlet.ServletException
    • pushForwardRequest

      void pushForwardRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
      Adds a request dispatcher to this context to simulate a forward request.
      Throws:
      javax.servlet.ServletException
    • popRequest

      void popRequest()
      Removes the top request dispatcher or filter from this context.
    • isFilterActive

      boolean isFilterActive()
      Returns true if the current context is a filter, rather than a servlet.
      Since:
      1.6
    • getFilter

      javax.servlet.Filter getFilter() throws javax.servlet.ServletException
      Returns the current active filter object. Only valid to call if isFilterActive() returns true.
      Throws:
      javax.servlet.ServletException
      Since:
      1.6
    • getFilterChain

      javax.servlet.FilterChain getFilterChain()
      Returns the current filter chain. Only valid to call if isFilterActive() returns true.
      Since:
      1.6
    • pushFilter

      void pushFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
      Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet. This can be used to simulate the effect of the doFilter call.
      Note: this method specifies ServletRequest and ServletResponse because those are the types passed to Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain); however, HttpUnit requires the objects to implement HttpServletRequest and HttpServletResponse because they will eventually be passed to an HttpServlet.
      Parameters:
      request - the request to pass to the next filter. May be a wrapper.
      response - the response object to pass to the next filter. May be a wrapper.
      Since:
      1.6