Monday, May 26, 2008

Redirect-after-Post pattern and Session bound ActionMessages

To deal with double submit problem, the Redirect after Post pattern is purposed in [1] and [2].
- Never show pages in response to POST
- Always load pages using GET
- Navigate from POST to GET using REDIRECT

To facilitate this, the errors/messages need to be stored in session scope, o/w they would get lost after redirect. From Struts 1.2.4, Action.saveMessages(HttpSession, ActionMessages) is added [3]. Upon the first access to the messages they are effectively removed from the session. This allows messages to be retained when using the redirect after post pattern.

ActionRedirect inherits from ActionForward, with support for adding parameters at runtime.

No comments: