Package org.apache.struts2.components
Class Include
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.Include
Include a servlet's output (result of servlet or a JSP page).
Note: Any additional params supplied to the included page are not accessible within the rendered page through the <s:property...> tag since no valuestack will be created. You can, however, access them in a servlet via the HttpServletRequest object or from a JSP page via a scriptlet.
- value* (String) - jsp page to be included
Examples
 
 <-- One: -->
 <s:include value="myJsp.jsp" />
 <-- Two: -->
 <s:include value="myJsp.jsp">
    <s:param name="param1" value="value2" />
    <s:param name="param2" value="value2" />
 </s:include>
 <-- Three: -->
 <s:include value="myJsp.jsp">
    <s:param name="param1">value1</s:param>
    <s:param name="param2">value2</s:param>
 </s:include>
 
 
 Example one - do an include myJsp.jsp page
 Example two - do an include to myJsp.jsp page with parameters param1=value1 and param2=value2
 Example three - do an include to myJsp.jsp page with parameters param1=value1 and param2=value2
 
 - 
Field SummaryFieldsFields inherited from class org.apache.struts2.components.ComponentactionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure
- 
Constructor SummaryConstructorsConstructorDescriptionInclude(ValueStack stack, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddParameter(String key, Object value) Adds the given key and value to this component's own parameter.booleanCallback for the end tag of this component.static StringgetContextRelativePath(jakarta.servlet.ServletRequest request, String relativePath) static voidinclude(String relativePath, Writer writer, jakarta.servlet.ServletRequest request, jakarta.servlet.http.HttpServletResponse response, String encoding) Include a resource in a response.voidsetDefaultEncoding(String encoding) voidsetUseResponseEncoding(String useEncoding) voidMethods inherited from class org.apache.struts2.components.ComponentaddAllAttributes, completeExpression, copyAttributes, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpression, toString, usesBody
- 
Field Details- 
value
 
- 
- 
Constructor Details- 
Includepublic Include(ValueStack stack, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) 
 
- 
- 
Method Details- 
setDefaultEncoding
- 
setUseResponseEncoding
- 
endDescription copied from class:ComponentCallback for the end tag of this component. Should the body be evaluated again?
 NOTE: will pop component stack.
- 
setValue
- 
getContextRelativePath
- 
addParameterDescription copied from class:ComponentAdds the given key and value to this component's own parameter.
 If the provided key is null nothing happens. If the provided value is null any existing parameter with the given key name is removed.- Overrides:
- addParameterin class- Component
- Parameters:
- key- the key of the new parameter to add.
- value- the value associated with the key.
 
- 
includepublic static void include(String relativePath, Writer writer, jakarta.servlet.ServletRequest request, jakarta.servlet.http.HttpServletResponse response, String encoding) throws jakarta.servlet.ServletException, IOException Include a resource in a response.- Parameters:
- relativePath- the relative path of the resource to include; resolves to- getContextRelativePath(jakarta.servlet.ServletRequest, String)
- writer- the Writer to write output to
- request- the current request
- response- the response to write to
- encoding- the file encoding to use for including the resource; if null, it will default to the platform encoding
- Throws:
- jakarta.servlet.ServletException- in case of servlet processing errors
- IOException- in case of IO errors
 
 
-