Interface InvocationContext
public interface InvocationContext
An interface which represents the invocation of a servlet.
- Author:
- Russell Gold
-
Method Summary
Modifier and TypeMethodDescriptionjavax.servlet.FilterReturns the current active filter object.javax.servlet.FilterChainReturns the current filter chain.getFrame()Returns the target frame for the original request.javax.servlet.http.HttpServletRequestReturns the request to be processed by the servlet or filter.javax.servlet.http.HttpServletResponseReturns the response which the servlet or filter should modify during its operation.javax.servlet.ServletReturns the selected servlet, initialized to provide access to sessions and servlet context information.Returns the final response from the servlet.booleanReturns true if the current context is a filter, rather than a servlet.voidRemoves the top request dispatcher or filter from this context.voidpushFilter(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.voidpushForwardRequest(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.voidpushIncludeRequest(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.voidservice()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
Invokes the current servlet or filter.- Throws:
javax.servlet.ServletExceptionIOException- Since:
- 1.6
-
getServlet
javax.servlet.Servlet getServlet() throws javax.servlet.ServletExceptionReturns the selected servlet, initialized to provide access to sessions and servlet context information. Only valid to call ifisFilterActive()returns false.- Throws:
javax.servlet.ServletException
-
getServletResponse
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
-
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.ServletExceptionReturns the current active filter object. Only valid to call ifisFilterActive()returns true.- Throws:
javax.servlet.ServletException- Since:
- 1.6
-
getFilterChain
javax.servlet.FilterChain getFilterChain()Returns the current filter chain. Only valid to call ifisFilterActive()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 thedoFiltercall.
Note: this method specifiesServletRequestandServletResponsebecause those are the types passed toFilter.doFilter(ServletRequest, ServletResponse, FilterChain); however, HttpUnit requires the objects to implementHttpServletRequestandHttpServletResponsebecause they will eventually be passed to anHttpServlet.- 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
-