Learn how to a build a cloud-first strategyRegister Now

x
  • 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?

Thanks
0
Anthony Lucia
Asked:
Anthony Lucia
2 Solutions
 
käµfm³d 👽Commented:
What does the web service return? HTML? Anything?
0
 
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.
0
 
dpearsonCommented:
In Java you generally call a "sendRedirect" method in the the servlet that is responding to the request:
http://www.javatpoint.com/sendRedirect()-method

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,

Doug
0

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