Viswa
Viswa

Reputation: 1377

RequestDispatcher

request.getRequestDispatcher("https://app.inpostlinks.com/login").forward(request, response);

I want to forward the request to the foreign URL like https://app.inpostlinks.com/login, not residing on the container where the servlet resides.

It's not getting forwarded. Are there any solutions on the above scenario?

Upvotes: 1

Views: 888

Answers (1)

Ant Kutschera
Ant Kutschera

Reputation: 6588

Forwarding is for passing say a servlets request and response to a JSP to do the presentation of the result of some business logic.

If you want to pass the user to a different website, you need to do a "redirect" instead of a "forward", ie get the server to return a 301 code and a location:

response.sendRedirect(url);

Upvotes: 4

Related Questions