org.apache.struts2.interceptor.debugging

## Class DebuggingInterceptor

- java.lang.Object
- - org.apache.struts2.interceptor.AbstractInterceptor
  - - com.opensymphony.xwork2.interceptor.AbstractInterceptor
    - - org.apache.struts2.interceptor.debugging.DebuggingInterceptor

- All Implemented Interfaces:
    Serializable, ConditionalInterceptor, Interceptor

      public class DebuggingInterceptor
      extends AbstractInterceptor

  Provides several different debugging screens to provide insight into the data behind the page.

  The value of the 'debug' request parameter determines the screen:

  - `xml` - Dumps the parameters, context, session, and value stack as an XML document.
  - `console` - Shows a popup 'OGNL Console' that allows the user to test OGNL expressions against the value stack. The XML data from the 'xml' mode is inserted at the top of the page.
  - `command` - Tests an OGNL expression and returns the string result. Only used by the OGNL console.
  - `browser` Shows field values of an object specified in the `object` parameter (action by default). When the `object` parameters is set, the '#' character needs to be escaped to '%23'. Like debug=browser&object=%23parameters

  Example:

  http://localhost:8080/Welcome.action?debug=xml

  This interceptor only is activated when devMode is enabled in struts.properties. The 'debug' parameter is removed from the parameter list before the action is executed. All operations occur before the natural Result has a chance to execute.

  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.opensymphony.xwork2.interceptor.ConditionalInterceptor

      `ConditionalInterceptor.LegacyAdapter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DebuggingInterceptor()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `intercept(ActionInvocation inv)` Override to handle interception
    `protected void` | `printContext()` Prints the current context to the response in XML format.
    `protected void` | `printContext(PrettyPrintWriter writer)` Prints the current request to the existing writer.
    `protected void` | `serializeIt(Object bean, String name, PrettyPrintWriter writer, List<Object> stack)` Recursive function to serialize objects to XML.
    `void` | `setDevMode(String mode)`
    `void` | `setEnableXmlWithConsole(boolean enableXmlWithConsole)`
    `void` | `setFreemarkerManager(FreemarkerManager mgr)`
    `void` | `setReflectionProvider(ReflectionProvider reflectionProvider)`

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor

      `intercept, shouldIntercept, shouldIntercept`

    - ### Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor

      `destroy, init, setDisabled`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.opensymphony.xwork2.interceptor.ConditionalInterceptor

      `adapt`

    - ### Methods inherited from interface com.opensymphony.xwork2.interceptor.Interceptor

      `adapt`

    - ### Methods inherited from interface org.apache.struts2.interceptor.Interceptor

      `destroy, init`

- - ### Constructor Detail

    - #### DebuggingInterceptor

          public DebuggingInterceptor()

  - ### Method Detail

    - #### setDevMode

          public void setDevMode(String mode)

    - #### setFreemarkerManager

          public void setFreemarkerManager(FreemarkerManager mgr)

    - #### setReflectionProvider

          public void setReflectionProvider(ReflectionProvider reflectionProvider)

    - #### intercept

          public String intercept(ActionInvocation inv)
                           throws Exception

      Description copied from class: `AbstractInterceptor`
      Override to handle interception
      Specified by:
        `intercept` in class `AbstractInterceptor`
      Throws:
        `Exception`

    - #### printContext

          protected void printContext()

      Prints the current context to the response in XML format.

    - #### printContext

          protected void printContext(PrettyPrintWriter writer)

      Prints the current request to the existing writer.
      Parameters:
        `writer` - The XML writer

    - #### serializeIt

          protected void serializeIt(Object bean,
                                     String name,
                                     PrettyPrintWriter writer,
                                     List<Object> stack)

      Recursive function to serialize objects to XML. Currently it will serialize Collections, maps, Arrays, and JavaBeans. It maintains a stack of objects serialized already in the current function call. This is used to avoid looping (stack overflow) of circular linked objects. Struts and XWork objects are ignored.
      Parameters:
        `bean` - The object you want serialized.
        `name` - The name of the object, used for element <name/>
        `writer` - The XML writer
        `stack` - List of objects we're serializing since the first calling of this function (to prevent looping on circular references).

    - #### setEnableXmlWithConsole

          public void setEnableXmlWithConsole(boolean enableXmlWithConsole)

      Parameters:
        `enableXmlWithConsole` - the enableXmlWithConsole to set

Copyright © 2000–2025 Apache Software Foundation. All rights reserved.