Response.seeOther returns blank screen

608 Views Asked by At

I need to redirect to a specific external url in my jersey web service

and I am using this method:

    public static Response redirectTo(String path) {
    URI uri;
    try {
        uri = new URI(path);
        return Response.seeOther(uri).build();
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return null;
    }
}

But it navigates to a white screen page and not to stackoverflow.com.

Why is it happening and how to fix it?

This method is called inside this method

@GET
    @Path("/login")
    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Response login(@Context UriInfo info, @Context HttpServletRequest request) {
...
String url = "http://stackoverflow.com";
redirectTo(url); 
}

the url of login method is called when triggering an event from AppDirect (via browser)

1

There are 1 best solutions below

0
eeadev On BEST ANSWER

I ended up in adding the @Context HttpServletResponse res parameter to my method and calling this method res.sendRedirect(urlApp);

This is working as expected.