Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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!

- 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.

Field Summary
`private static Log` | `_log`
`private static String` | `defaultEncoding`
`private static String` | `encoding`
`private static boolean` | `encodingDefined`
`private HttpServletRequest` | `req`
`private HttpServletResponse` | `res`
`protected String` | `value`

Fields inherited from class org.apache.struts2.components.Component
`actionMapper, COMPONENT_STACK, id, parameters, stack`

Constructor Summary
`Include(ValueStack stack, HttpServletRequest req, HttpServletResponse res)`

Method Summary
`void` | `addParameter(String key, Object value)` Add's the given key and value to this components own parameter.
`boolean` | `end(Writer writer, String body)` Callback for the end tag of this component.
`static String` | `getContextRelativePath(ServletRequest request, String relativePath)`
`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.
`static void` | `include(String aResult, Writer writer, ServletRequest request, HttpServletResponse response)`
`static void` | `setDefaultEncoding(String encoding)`
`void` | `setValue(String value)`

Methods inherited from class org.apache.struts2.components.Component
`addAllParameters, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setActionMapper, setId, start, toString, usesBody`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _log

    private static final Log _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

Constructor Detail

### Include

    public Include(ValueStack stack,
                   HttpServletRequest req,
                   HttpServletResponse res)

Method Detail

### setDefaultEncoding

    public static 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`
  Add's the given key and value to this components own parameter.

  If the provided key is `null` nothing happends. 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.