# Configuring Page Flow Applications

The following topic explains how to prevent exhaustion of resources in your page flow because of (1) large numbers of server forwards and (2) large nesting stacks.

## Limiting the Number of Server Forwards

The maximum number of server forwards allowed within a single request can be configured in the file WEB-INF/web.xml using the jpf-forward-overflow-count parameter.

        <context-param>
            <param-name>jpf-forward-overflow-count</param-name>
            <param-value>10</param-value>
        </context-param>

The <context-param> element should be a direct child of the <web-app> element.

If the number of server forwards exceeds the given count, an error is written to the response and no further forwarding is excuted. This is mainly to prevent infinite loops of server forwards. To reproduce the error, invoke this action in a Page Flow:

        /**
         * @jpf:action
         * @jpf:forward name="self" path="overflow.do"
         */
        public Forward overflow()
        {
            return new Forward( "self" );
        }

If the jpf-forward-overflow-count parameter is ommitted from the web.xml file, the error will be written to the response after 50 server forwards within a single request.

## Limiting the Number of Nested Page Flows

The maximum depth of the Page Flow nesting stack can be configured in WEB-INF/web.xml using the jpf-nesting-overflow-count parameter.

        <context-param>
            <param-name>jpf-nesting-overflow-count</param-name>
            <param-value>10</param-value>
        </context-param>

The <context-param> element should be a direct child of the <web-app> element.

This parameter set the maximum size of the Page Flow nesting stack. If Page Flow are repeatedly nested until the stack exceeds the specified value, an error is written to the response object and any further nesting is not allowed. This helps prevent the nesting stack from consuming large amounts of resources.