Class RequestStateHelper
java.lang.Object
org.deltava.util.redirect.RequestStateHelper
A utility class to save and restore servlet request state.
- Since:
- 1.0
- Version:
- 11.1
- Author:
- Luke
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the HTTP session attribute used to save servlet request state. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear(jakarta.servlet.http.HttpServletRequest req) Helper method to remove the request state object from the session, if found.static Stringrestore(jakarta.servlet.http.HttpServletRequest req) Restores the current servlet request state.static voidSaves the current servlet request state to the current HTTP session.
-
Field Details
-
STATE_ATTR_NAME
The name of the HTTP session attribute used to save servlet request state.- See Also:
-
-
Method Details
-
restore
Restores the current servlet request state. This will load the request state from the current HTTP session and populate the request attributes. Existing request attributes will be overwritten.- Parameters:
req- the current servlet request- Returns:
- the URL to forward to
- Throws:
IllegalStateException- if there is no current HTTP session, or the request state attribute is not present in the session
-
save
Saves the current servlet request state to the current HTTP session.- Parameters:
req- the current servlet requesturl- the URL to forward to after the servlet request state is restored- Throws:
IllegalStateException- if an HTTP session does not currently exist
-
clear
public static void clear(jakarta.servlet.http.HttpServletRequest req) Helper method to remove the request state object from the session, if found.- Parameters:
req- the current servlet request
-