Search code examples
shellcgi-bin

What's the cgi-bin equivalent of getRequestDispatcher("/myURL").forward(request, response)?


I'm using #!/bin/sh as my language.


Solution

  • Doing a redirect would be easy. Just return the right HTTP header like:

    Location: http://www.w3.org/pub/WWW/People.html
    

    The problem is that the user will see the URL change in their browser.

    Technically "forward" is a internal redirect which is normally supported by your "framework" (ie the Servlet API that you specified). I guess to get an "internal forward" to work in #!/bin/sh you would need to do something like this (psuedocode)

    # before i've printed anything to the output
    if "should i forward"
      my_other_cgi_page.sh
      exit
    fi