We can do it by the following steps.
- Set HANDLE_REDIRECTS parameter value to false , that means it defines redirects should be handled manually
- Then after executing our request, if it is not HttpStatus.SC_OK or when response codes between 300 and 399 ( redirect responses )
- Gets the values of the response header with the name as "Location"
- the last value will be the new url where it need to redirect
- then execute the new request using the redirect url by setting the needed parameters
Hope this help.
And please feel free to point out my mistakes...