I have a requirement to collect some info from casual visitor to the site (unauthenticated) using AEM Forms. On posting data to backend (custom rest endpoint), there may be some validation failures - in which case, the form should be rendered back to the user with the data filled in (whatever was just entered) along with an error message. The validation cannot be done from client side. I tried the 3 options below, none of them seem to work.
SlingHttpServletRequest wrappedErrorRequest = new CustomParameterRequest(slingRequest, "GET");
In case of option 1 & 2, I get an error "resource cannot be modified". Turns out that I cannot forward to a page. With option 3, the request attributes are lost after the redirect. Any suggestions on how to resolve this?