Package org.springframework.mock.web
Class MockPageContext
java.lang.Object
jakarta.servlet.jsp.JspContext
jakarta.servlet.jsp.PageContext
org.springframework.mock.web.MockPageContext
Mock implementation of the 
PageContext interface.
 Only necessary for testing applications when testing custom JSP tags.
 Note: Expects initialization via the constructor rather than via the
 PageContext.initialize method. Does not support writing to a
 JspWriter, request dispatching, or handlePageException calls.
- Since:
- 1.0.2
- Author:
- Juergen Hoeller
- 
Field SummaryFields inherited from class jakarta.servlet.jsp.PageContextAPPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate new MockPageContext with a defaultMockServletContext,MockHttpServletRequest,MockHttpServletResponse,MockServletConfig.MockPageContext(ServletContext servletContext) Create new MockPageContext with a defaultMockHttpServletRequest,MockHttpServletResponse,MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request) Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) Create new MockPageContext with a MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, ServletConfig servletConfig) Create new MockServletConfig.
- 
Method SummaryModifier and TypeMethodDescriptionfindAttribute(String name) voidgetAttribute(String name) getAttribute(String name, int scope) getAttributeNamesInScope(int scope) intgetAttributesScope(String name) byte[]Deprecated.getOut()getPage()Deprecated.voidvoidvoidvoidvoidinitialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) voidrelease()voidremoveAttribute(String name) voidremoveAttribute(String name, int scope) voidsetAttribute(String name, Object value) voidsetAttribute(String name, Object value, int scope) Methods inherited from class jakarta.servlet.jsp.PageContextgetErrorData, pushBodyMethods inherited from class jakarta.servlet.jsp.JspContextpopBody, pushBody
- 
Constructor Details- 
MockPageContextpublic MockPageContext()Create new MockPageContext with a defaultMockServletContext,MockHttpServletRequest,MockHttpServletResponse,MockServletConfig.
- 
MockPageContextCreate new MockPageContext with a defaultMockHttpServletRequest,MockHttpServletResponse,MockServletConfig.- Parameters:
- servletContext- the ServletContext that the JSP page runs in (only necessary when actually accessing the ServletContext)
 
- 
MockPageContextpublic MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request) Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.- Parameters:
- servletContext- the ServletContext that the JSP page runs in
- request- the current HttpServletRequest (only necessary when actually accessing the request)
 
- 
MockPageContextpublic MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request, @Nullable HttpServletResponse response) Create new MockPageContext with a MockServletConfig.- Parameters:
- servletContext- the ServletContext that the JSP page runs in
- request- the current HttpServletRequest
- response- the current HttpServletResponse (only necessary when actually writing to the response)
 
- 
MockPageContextpublic MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable ServletConfig servletConfig) Create new MockServletConfig.- Parameters:
- servletContext- the ServletContext that the JSP page runs in
- request- the current HttpServletRequest
- response- the current HttpServletResponse
- servletConfig- the ServletConfig (hardly ever accessed from within a tag)
 
 
- 
- 
Method Details- 
initializepublic void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) - Specified by:
- initializein class- PageContext
 
- 
releasepublic void release()- Specified by:
- releasein class- PageContext
 
- 
setAttribute- Specified by:
- setAttributein class- JspContext
 
- 
setAttribute- Specified by:
- setAttributein class- JspContext
 
- 
getAttribute- Specified by:
- getAttributein class- JspContext
 
- 
getAttribute- Specified by:
- getAttributein class- JspContext
 
- 
findAttribute- Specified by:
- findAttributein class- JspContext
 
- 
removeAttribute- Specified by:
- removeAttributein class- JspContext
 
- 
removeAttribute- Specified by:
- removeAttributein class- JspContext
 
- 
getAttributesScope- Specified by:
- getAttributesScopein class- JspContext
 
- 
getAttributeNames
- 
getAttributeNamesInScope- Specified by:
- getAttributeNamesInScopein class- JspContext
 
- 
getOut- Specified by:
- getOutin class- JspContext
 
- 
getExpressionEvaluatorDeprecated.- Specified by:
- getExpressionEvaluatorin class- JspContext
 
- 
getELContext- Specified by:
- getELContextin class- JspContext
 
- 
getVariableResolverDeprecated.- Specified by:
- getVariableResolverin class- JspContext
 
- 
getSession- Specified by:
- getSessionin class- PageContext
 
- 
getPage- Specified by:
- getPagein class- PageContext
 
- 
getRequest- Specified by:
- getRequestin class- PageContext
 
- 
getResponse- Specified by:
- getResponsein class- PageContext
 
- 
getException- Specified by:
- getExceptionin class- PageContext
 
- 
getServletConfig- Specified by:
- getServletConfigin class- PageContext
 
- 
getServletContext- Specified by:
- getServletContextin class- PageContext
 
- 
forward- Specified by:
- forwardin class- PageContext
- Throws:
- ServletException
- IOException
 
- 
include- Specified by:
- includein class- PageContext
- Throws:
- ServletException
- IOException
 
- 
include- Specified by:
- includein class- PageContext
- Throws:
- ServletException
- IOException
 
- 
getContentAsByteArraypublic byte[] getContentAsByteArray()
- 
getContentAsString- Throws:
- UnsupportedEncodingException
 
- 
handlePageException- Specified by:
- handlePageExceptionin class- PageContext
- Throws:
- ServletException
- IOException
 
- 
handlePageException- Specified by:
- handlePageExceptionin class- PageContext
- Throws:
- ServletException
- IOException
 
 
-