---
title: StaticResponseHandler
description: Creates a response to a request statically, or based on something in the context.
component: pinggateway
version: 2026
page_id: pinggateway:reference:StaticResponseHandler
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/StaticResponseHandler.html
revdate: 2025-06-02T18:01:47Z
section_ids:
  StaticResponseHandler-usage: Usage
  StaticResponseHandler-properties: Properties
  StaticResponseHandler-example: Example
---

# StaticResponseHandler

Creates a response to a request statically, or based on something in the context.

## Usage

```json
{
  "name": string,
  "type": "StaticResponseHandler",
  "config": {
    "status": configuration expression<number>,
    "reason": configuration expression<string>,
    "headers": {
       configuration expression<string>: [ runtime expression<string>, ... ], ...
    },
    "trailers": {
       configuration expression<string>: [ runtime expression<string>, ... ], ...
    },
    "entity": runtime expression<string> or [ runtime expression<string>, ... ]
  }
}
```

## Properties

* `"status"`: *Status object*

  The response status. Learn more in [Status](Status.html).

* `"reason"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  Used only for custom HTTP status codes. Learn more in [Response Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) and [Status Code Registry](https://datatracker.ietf.org/doc/html/rfc7231#section-8.2).

* `"headers"`: *[map](preface.html#definition-map), optional*

  One or more headers to set for a response, with the format `name: [ value, …​ ]`, where:

  * *name* is a configuration expression<[string](preface.html#definition-string)> for a header name. If multiple expressions resolve to the same final string, *name* has multiple values.

  * *value* one or more a runtime expression<[strings](preface.html#definition-string)> for header values.

  When the property `entity` is used, set a `Content-Type` header with the correct content type value. The following example sets the content type of a message entity in the response:

  ```json
  "headers": {
    "Content-Type": [ "text/html; charset=UTF-8" ]
  }
  ```

  The following example redirects the original URI from the request:

  ```json
  "headers": {
    "Location": [
       "https://sp.example.com:8443/saml/SPInitiatedSSO"
    ]
  }
  ```

Default: Empty

* `"trailers"`: *[map](preface.html#definition-map), optional*

  One or more trailers to set for a response, with the format `name: [ value, …​ ]`, where:

  * *name* is a configuration expression<[string](preface.html#definition-string)> for a trailer name. If multiple expressions resolve to the same string, *name* has multiple values.

    The following trailer names aren't allowed:

    * Message framing headers (for example, `Transfer-Encoding` and `Content-Length`)

    * Routing headers (for example, `Host`)

    * Request modifiers (for example, controls and conditionals such as `Cache-Control`, `Max-Forwards`, and `TE`)

    * Authentication headers (for example, `Authorization` and `Set-Cookie`)

    * `Content-Encoding`

    * `Content-Type`

    * `Content-Range`

    * `Trailer`

  * *value* is one or more runtime expression<[strings](preface.html#definition-string)> for trailer values.

Default: Empty

* `"entity"`: *runtime expression<[string](preface.html#definition-string)>* or *array of runtime expression<[string](preface.html#definition-string)>, optional*

  The message entity body to include in a response.

  If a `Content-Type` header is present, the entity must conform to the header and set the content length header automatically.

  Methods are provided for accessing the entity as byte, string, or JSON content. Learn more in [Entity](../_attachments/apidocs/org/forgerock/http/protocol/Entity.html).

  |   |                                                                                                                                                                                                                        |
  | - | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  |   | Attackers during reconnaissance can use response messages to identify information about a deployment. For security, limit the amount of information in messages, and avoid using words that help identify PingGateway. |

  Default: Empty

## Example

```json
{
  "name": "ErrorHandler",
  "type":"StaticResponseHandler",
  "config": {
    "status": 500,
    "headers": {
      "Content-Type": [ "text/html; charset=UTF-8" ]
    },
    "entity": "<html><h2>Epic #FAIL</h2></html>"
  }
}
```

```json
{
  "handler": {
    "type": "StaticResponseHandler",
    "config": {
      "status": 200,
      "headers": {
        "content-type": [ "text/html" ]
      },
      "entity": [
        "<html>",
        "  <body>",
        "    <h1>Request Details</h1>",
        "    <p>The path was: ${request.uri.path}<p>",
        "    <p>The query params were: ${toString(request.queryParams)}</p>",
        "    <p>The headers were: ${toString(request.headers.entrySet())}<p>",
        "  </body>",
        "</html>"
      ]
    }
  }
}
```
