Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Web service and redirection

Lets say I write a web service,where that is a HTTP request / response service

Within that service, I want to have the browser that called me be redirected to another site.  

How can I perform that , what would that look like?

Anthony Lucia
Anthony Lucia
2 Solutions
käµfm³d 👽Commented:
What does the web service return? HTML? Anything?
Jaime OlivaresCommented:
your web service should return some data (xml, json, etc.). You can redirect the data location with a HTTP header, but that won't force the calling client to redirect to a different site.
In Java you generally call a "sendRedirect" method in the the servlet that is responding to the request:

This causes the user's browser to redirect to the new URL.  Other frameworks/languages should offer something similar.

If you're asking more deeply how this actually triggers the browser to do the redirect, I think it's by sending a response code that indicates that the URL has temporarily changed location.  If memory serves that's status code 307 (it'll be in the 300s - they're for moved/redirected resources) - anyway it's part of the HTTP spec.

Hope that helps,


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now