org.apache.struts2.components
Class Include
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.Include
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.
- 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
Nested Class Summary |
(package private) static class |
Include.PageOutputStream
Implementation of ServletOutputStream that stores all data written
to it in a temporary buffer accessible from Include.PageOutputStream.getBuffer() . |
(package private) static class |
Include.PageResponse
Simple wrapper to HTTPServletResponse that will allow getWriter()
and getResponse() to be called as many times as needed without
causing conflicts. |
Methods inherited from class org.apache.struts2.components.Component |
addAllParameters, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getParameters, getStack, popComponentStack, setActionMapper, start, toString, usesBody |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
private static final Logger LOG
encoding
private static String encoding
encodingDefined
private static boolean encodingDefined
value
protected String value
req
private HttpServletRequest req
res
private HttpServletResponse res
defaultEncoding
private static String defaultEncoding
Include
public Include(ValueStack stack,
HttpServletRequest req,
HttpServletResponse res)
setDefaultEncoding
public void setDefaultEncoding(String encoding)
end
public boolean end(Writer writer,
String body)
- Description copied from class:
Component
- Callback for the end tag of this component.
Should the body be evaluated again?
NOTE: will pop component stack.
- Overrides:
end
in class Component
- Parameters:
writer
- the output writer.body
- the rendered body.
- Returns:
- true if the body should be evaluated again
setValue
public void setValue(String value)
getContextRelativePath
public static String getContextRelativePath(ServletRequest request,
String relativePath)
addParameter
public void addParameter(String key,
Object value)
- Description copied from class:
Component
- Adds 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:
addParameter
in class Component
- Parameters:
key
- the key of the new parameter to add.value
- the value assoicated with the key.
include
public static void include(String aResult,
Writer writer,
ServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- Throws:
ServletException
IOException
getEncoding
private static String getEncoding()
- Get the encoding specified by the property 'struts.i18n.encoding' in struts.properties,
or return the default platform encoding if not specified.
Note that if the property is not initially defined, this will return the system default,
even if the property is later defined. This is mainly for performance reasons. Undefined
properties throw exceptions, which are a costly operation.
If the property is initially defined, it is read every time, until is is undefined, and then
the system default is used.
Why not cache it completely? Some applications will wish to be able to dynamically set the
encoding at runtime.
- Returns:
- The encoding to be used.
Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.