Best way redirect REST service request on glassfish + JAX-RS to https URL?

191 views Asked by At

I have implemented a REST service on glassfish4 + JAX-RS. Now I want use a https connection for authentication.

The URI for http is http://myhost/myapp/services/rest/myservice and for https is https://myhost_2/myapp/services/rest/myservice. I want prevent the usage of http://myhost/myapp/services/rest/myservice.

I think one way is redirect a request over http://myhost in the REST JAX-RS class to https://myhost_2. Is this a good way? How can I implement this?

1

There are 1 answers

1
sschrass On BEST ANSWER

you could answer requests to http with 301 (Moved permanently, telling the client to use the new location in future requests) pointing to the https equivalent in the location header of the response.