Jersey Redirect to another Resource

In this tutorial we will see how to redirect url using restful webservice in java. Sometime we need to redirect to other url or server .For example , when we do verification of email id then we send mail to user with a link. User click on link we need to verify user and sent to front end server or other url as per our application requirement . Before learning jersey redirect to another resource you should have idea about restful webservice in java . I recommended to you read first jersey rest api tutorial first. We will discuss how to jersey send redirect request , you should first create restful webservice example . Now In this example we will create get api whichforward request to another url.

How to  redirect to any url in jersey

@GET
@Path("/user")
public Response userVerification(@Context Response response){

java.net.URI location = new java.net.URI("http://www.ariseter.com");
return Response.temporaryRedirect(location).build();

}

This is example we will redirect to www.ariseter.com url . In this example we call rest api with GET method but our client follow redirect to other url after call compilation of task. you can read more jersey example for beginners . This example is helpful when we need to redirect our follow to  other server or url after completing task .

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 4 =