0

I have a random bug in my JSF app that strips all my HTTP parameters. It happens randomly and I can't get any error messages (even when following BalusC's advice here and here).

I can't pinpoint the cause and fix it so I'm wondering if another solution is possile: forcing the request to be resent if all my parameters are empty. Is there a way to make the browser resend its request? For example, through a JSF or HTTP error code.

EDIT: Cleaned up unnecessary code.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Pascal
  • 259
  • 1
  • 11
  • 27
  • Can you please share some code so we can check what is going on? – user1156544 Jul 03 '17 at 10:17
  • I would try what you say as a last resort (I think it's an ugly patch). Actually there's a way to force the browser to resend a request, sending a REDIRECT response. However, for achieving that, you'll probably need to intercept the request in a request filter and send the redirect response from here, without getting JSF involved. – Aritz Jul 03 '17 at 11:08
  • Yeah, it _is_ an ugly patch. I've been trying for some weeks to fix this with no success. – Pascal Jul 03 '17 at 11:11
  • Can you try debugging the FormulairesManagedBean constructor and see what values the fields hold at the end ? – OTM Jul 03 '17 at 17:02

1 Answers1

0

In the end, I followed @Xtreme Biker's advice and instead built a filter. It checks if parameters are present, otherwise it sends a redirect response (HTTP error code 307). Then the browser send back the same request which proceeds through.

Something like:

String formWebContainerWidth = httpRequest.getParameter("myParam");
if(formWebContainerWidth == null){

    // SC_TEMPORARY_REDIRECT = 307
    httpResponse.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
    httpResponse.setHeader("Location", httpRequest.getRequestURI()); 
} else {
   chain.doFilter(request, response);
}

EDIT: Added the location, otherwise the browser sometimes displays a "page cannot be reached" error message.

Pascal
  • 259
  • 1
  • 11
  • 27