Alex Rivera | Logout

Redirecting to a page using restful methods?

Asked 2012-06-20T09:35:53.680
10

I've created a page which asks user to fill some form fields and when he submits, the form is sent to a Restful method which you can see below:

@POST
@Path("addUser")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void addUser(@FormParam("username") String username,
        @FormParam("password") String password,
        @FormParam("id") String id,
        @FormParam("group_name") String groupName,
        @FormParam("authority_name") String authorityName,
        @FormParam("authority_id") String authorityId
        )
{
    //Something will be done here
}


How can I redirect the user at the end of this function to (let's say) index.jsp?

Edit
Report

1 Answer

12

Create a URI using javax.ws.rs.core.UriBuilder that maps the parameters and other data you want to preserve. Then use Response.temporaryRedirect to return a redirect to the client and pass it the URI you’ve built.

answered 2012-06-20T09:40:56.337

Your Answer