public class Include extends Component
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.
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
Modifier and Type | Field and Description |
---|---|
protected String |
value |
actionMapper, COMPONENT_STACK, devMode, parameters, stack, standardAttributesMap, throwExceptionOnELFailure
Constructor and Description |
---|
Include(ValueStack stack,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(String key,
Object value)
Adds the given key and value to this component's own parameter.
|
boolean |
end(Writer writer,
String body)
Callback for the end tag of this component.
|
static String |
getContextRelativePath(javax.servlet.ServletRequest request,
String relativePath) |
static void |
include(String relativePath,
Writer writer,
javax.servlet.ServletRequest request,
javax.servlet.http.HttpServletResponse response,
String encoding)
Include a resource in a response.
|
void |
setDefaultEncoding(String encoding) |
void |
setUseResponseEncoding(String useEncoding) |
void |
setValue(String value) |
addAllParameters, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, getStandardAttributes, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, toString, usesBody
protected String value
public Include(ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
public void setDefaultEncoding(String encoding)
public void setUseResponseEncoding(String useEncoding)
public boolean end(Writer writer, String body)
Component
public void setValue(String value)
public static String getContextRelativePath(javax.servlet.ServletRequest request, String relativePath)
public void addParameter(String key, Object value)
Component
addParameter
in class Component
key
- the key of the new parameter to add.value
- the value associated with the key.public static void include(String relativePath, Writer writer, javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response, String encoding) throws javax.servlet.ServletException, IOException
relativePath
- the relative path of the resource to include; resolves to getContextRelativePath(javax.servlet.ServletRequest,
String)
writer
- the Writer to write output torequest
- the current requestresponse
- the response to write toencoding
- the file encoding to use for including the resource; if null, it will default to the
platform encodingjavax.servlet.ServletException
- in case of servlet processing errorsIOException
- in case of IO errorsCopyright © 2000–2020 Apache Software Foundation. All rights reserved.