#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    17
    Rep Power
    0

    help with redirecting


    Hi All,

    I'm new to the jsp environment and am not quite sure how to get this done:

    I have a test.jsp on a machine where I collect information from the user and then go to a specific host to gather some diagnostics.

    I do not know how to redirect the URL to a specific host/machine to run the processes there.
    This is what I'm getting:
    http://abc:9040/def/test.jsp/nac?app...aaa&action=rrr

    This is what I want:
    http://www-blah.blah-blah.com/host/n...aaa&action=rrr

    I do not know how to redirect from "abc:9040/def/test.jsp" to "www-blah.blah-blah.com/host" and still retain the user params

    This is a sniplet of the code:
    Code:
    <h3>nac</h3>
    <FORM method="GET" action=<%= request.getContextPath()+ "/servlet/nac.nac"%>>
    AppId <input type=text name="appid" value="sample">
    Host <input type=text name="host" value="">
    Action <input type=text name="action" value="start">
    <input type=submit name="admin" value="do it">
    </FORM>
    <br><br>
    Any ideas?


    Thanks,
    Julie
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    If you want to submit to another host, you have to hard code that hosts name in the action. When using a relative path (where you don't specify a host), the browser always adds the current pages host name to the beginning of links.
    Code:
    <h3>nac</h3>
    <FORM method="GET" action="www-blah.blah-blah.com/servlet/nac.nac">
    AppId <input type=text name="appid" value="sample">
    Host <input type=text name="host" value="">
    Action <input type=text name="action" value="start">
    <input type=submit name="admin" value="do it">
    </FORM>
    <br><br>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    17
    Rep Power
    0
    Thanks for replying!

    I have another question:

    what if my redirect is dependant on the user input in the form?

    Code:
    <h3>nac</h3>
    <FORM method="GET" action="www-blah.blah-blah.com/host/servlet/nac.nac">
    AppId <input type=text name="appid" value="sample">
    Host <input type=text name="host" value="abc">
    Action <input type=text name="action" value="start">
    <input type=submit name="admin" value="do it">
    </FORM>
    <br><br>
    How can I code it so that after the user enters appid, action, and host, the jsp will go to user specific specific host?

    Basically, I'm trying go to a host, lookup the appid, and perform the action.

    Thanks,
    Julie
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Hmm, you are saying you want to determine the host based on what the user enters? If so, then you are going to have to use some javascript. Something like:
    Code:
    <script>
    function formSubmitter(f) {
      var preUrl = "www-blah.blah-blah.com/";
      var postUrl = "/servlet/nac.nac";
      f.action = preUrl + f.host.value + postUrl;
    }
    </script>
    
    <h3>nac</h3>
    <FORM method="GET" action="" onsubmit='formSubmitter(this)'>
    AppId <input type=text name="appid" value="sample">
    Host <input type=text name="host" value="">
    Action <input type=text name="action" value="start">
    <input type=submit name="admin" value="do it">
    </FORM>
    <br><br>
    Note, I did not test this code, it is off the top of my head and may need to be modified.

IMN logo majestic logo threadwatch logo seochat tools logo