Web service and redirection

Posted on 2014-08-27
Last Modified: 2014-08-28
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?

Question by:Anthony Lucia
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    What does the web service return? HTML? Anything?
    LVL 55

    Assisted Solution

    by:Jaime Olivares
    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.
    LVL 26

    Accepted Solution

    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,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
    This video is a brief demonstration on how to use security groups and Network Access Control Lists (ACLs) in Amazon Web Services.  Security groups and Network ACLs are mechanisms you can use in AWS to control network traffic.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now