title: Jersey jax.rs client 2.5 follow redirect from HTTP to HTTPS
body: <p>I have a setup where tomcat server hosting my REST servers redirects calls from HTTP (port 9080) to HTTPS ( port 9443 ).</p>
  
  <p>I'm using jersey 2.5 implementation and cannot manage to configure the clients to follow redirections.</p>
  
  <p>I've found this SO question( <a href="https://stackoverflow.com/questions/11305520/jersey-client-doesnt-follow-redirects">Jersey client doesn&#39;t follow redirects</a> ), however it's provided for jersey 1.X series and the API has changed.</p>
  
  <p>I've tried to adapt it for 2.5 with the following test code : </p>
  
  <pre><code> SSLContextProvider ssl = new TrustAllSSLContextImpl(); // just trust all certs
   Response response  =     ClientBuilder.newBuilder()
       .sslContext(ssl.getContext()).newClient()
       .register(LoggingFilter.class)
       .target("http://testhost.domain.org:9080/rest.webapp/api/v1/hello/")
       .property(ClientProperties.FOLLOW_REDIRECTS, Boolean.TRUE)
       .request().get();   
   Assertions.assertThat(response.getStatus()).isNotEqualTo(302);
  </code></pre>
  
  <p>Which fails as the client does not seem to follow the redirections. Here is what the logging filter provides : </p>
  
  <pre><code>Feb 14, 2014 12:23:45 PM org.glassfish.jersey.filter.LoggingFilter log
  INFO: 1 * Sending client request on thread main
  1 &gt; GET http://testhost.domain.org:9080/rest.webapp/api/v1/hello/
  
  Feb 14, 2014 12:23:45 PM org.glassfish.jersey.filter.LoggingFilter log
  INFO: 1 * Client response received on thread main
  1 &lt; 302
  1 &lt; Cache-Control: private
  1 &lt; Content-Length: 0
  1 &lt; Date: Fri, 14 Feb 2014 11:38:59 GMT
  1 &lt; Expires: Thu, 01 Jan 1970 01:00:00 CET
  1 &lt; Location: https://testhost.domain.org:9443/rest.webapp/api/v1/hello/
  1 &lt; Server: Apache-Coyote/1.1
  </code></pre>
  
  <p>From the jersey doc I understood that all that needs to be done is to add the ClientProperties.FOLLOW_REDIRECTS property to the client, but this obviously not to be the case.I've also found messages indicating that maybe a client side filter is required to follow the redirections, but found no examples or guidelines on this.</p>
  
  <p>So if anyone having some experience with jax.rs and redirection could point me to some directions/docs/example code I'd really appreciate.</p>