Class RequestStateHelper

java.lang.Object
org.deltava.util.redirect.RequestStateHelper

public final class RequestStateHelper extends Object
A utility class to save and restore servlet request state.
Since:
1.0
Version:
11.1
Author:
Luke
  • Field Details

    • STATE_ATTR_NAME

      public static final String STATE_ATTR_NAME
      The name of the HTTP session attribute used to save servlet request state.
      See Also:
  • Method Details

    • restore

      public static String restore(HttpServletRequest req)
      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

      public static void save(HttpServletRequest req, String url)
      Saves the current servlet request state to the current HTTP session.
      Parameters:
      req - the current servlet request
      url - 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(HttpServletRequest req)
      Helper method to remove the request state object from the session, if found.
      Parameters:
      req - the current servlet request