If a component is marked with request scope, simultaneous requests each see a different instance of the component. This is true even when the same session sends two requests simultaneously; each request gets a pointer to a separate object. All instances are handled independently and have no effect on each other.

Request scope can be especially useful for components whose properties are set by a form. When a form is submitted, the component values are set by their by the appropriate setX methods, and actions are performed by handleX methods.

If two forms are submitted at the same time to the same component, one submission might overwrite the setX methods of the other. This is especially true for globally-scoped components, which are highly vulnerable to multiple simultaneous requests from different sessions; with a session-scoped component, multiple simultaneous requests occur only if the user submits the form twice in very rapid succession. As a general rule, it is a good idea for forms to use request-scoped components; this ensures that only one request at a time can set their properties.

Note: To ensure that multiple requests do not access the same component simultaneously, you can also set the synchronized attribute in the form tag. With this attribute, the ATG platform locks the specified component before setting any properties, and releases the lock only after form submission is complete. Other form submissions can set the component’s properties only after the lock is released. For more information, see the Forms chapter in the ATG Page Developer’s Guide.

The component/atg/dynamo/servlet/pipeline/RequestScopeManager lets you view the request-scoped Nucleus hierarchy for the last few requests made to the Dynamo server. Each time a request comes into the browser, it creates a request scope and a tree of components. Request scopes are recycled as requests come in to the server.

Preserving request scoped objects on redirects

If a request results in a redirect to a local page through the method HttpServletResponse.sendLocalRedirect(), the ATG platform treats the redirect request as part of the original request, and maintains any request-scoped objects associated with that request. To implement this, the ATG platform adds an additional query parameter named _requestid to the redirected URL.

If desired, you can change the default behavior by setting the following property in the component /atg/dynamo/servlet/pipeline/RequestScopeManager:

saveRequestScopeOnRedirect=false

 
loading table of contents...