JSF: redirect to url as POST not as GET

I have a JSF page that redirects through context.getExternalContext().redirect(url); where url is sth. e.g. login.jsf? token = foobar

Now I want to send the token via POST not through a GET request. So that it doesn't appear in the url, is this possible with JSF?

+8
redirect post get jsf request
source share
2 answers

This is not possible with HTTP, therefore also not with JSF. However, there are several ways to achieve this requirement.

Place it in the session area. In the bean behind the redirected page, read and remove it from the session area. Or, when you are using JSF 2.0, use the flash area.

Go to the page containing the POST form pointing to the desired URL, having the token as a hidden input value and including some JS code that form.submit() does when the page loads.

+15
source share

Yes, you can do this by redirecting the backup bean to a temporary page containing all hidden values ​​and use form.submit(); Example:

Bean Support:

 public String submitValue() { return "temp"; } 

temporary.jsf

 <h:form id="JsfTemp" prependId="false"> <h:outputText id="welcomeOutput" value="Test Sending form"/> <h:inputHidden id="Merchant_Number" value="#{paymentBean.paymentDetails.merchantNumber}" /> </h:form> </body> <script type="text/javascript"> function submitPage() { document.getElementById("JsfTemp").action="http://localhost:9090/TestClient/HelloWorld"; document.getElementById("JsfTemp").submit(); } submitPage(); </script> 
+8
source share

All Articles