www.webdeveloper.com
Results 1 to 11 of 11

Thread: How to redirect a jsp to another jsp on the click of cancel button

  1. #1
    Join Date
    Apr 2008
    Posts
    15

    How to redirect a jsp to another jsp on the click of cancel button

    hi
    I want to redirect my jsp page to another jsp page on the click
    of cancel button without the validations been called on the click of
    cancel button
    Actually in my code when i click the cancel button it
    calls the validations javascript also which i dont want
    pls can anybody help me
    thanks and regards,

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Quote Originally Posted by java_crazy
    Actually in my code when i click the cancel button it
    calls the validations javascript also which i dont want
    Remove the event for the button

    Can you show the code you now use?

  3. #3
    Join Date
    Apr 2008
    Posts
    15
    hi fang,

    i tried this code.
    this is working in Mozilla but not internet explorer

    <a href="CardDetailForm.jsp"><input type="button" value="Cancel" name="cancel"/></a>

    regards,

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <a href="CardDetailForm.jsp"><input onclick="this.parentNode.href=null;" type="button" value="Cancel" name="cancel"/></a>
    Why you would do something like this is puzzling.

  5. #5
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    It depends on the meaning of "cancel" in the application but in general you should never go from one JSP to another. Your JSP should post to a servlet that deals with the request then forwards to the other JSP.

  6. #6
    Join Date
    Apr 2008
    Posts
    15
    My code given above is working properly in mozila but not in internet explorer
    can anybody help me
    what is the reason ie is not able to recognise

    i also tried the code suggested by fang
    but this not working in both
    ??

  7. #7
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The code prevents the link from working.
    Perhaps we don't fully understand what you want to cancel.

  8. #8
    Join Date
    Apr 2008
    Posts
    15
    Actually i dont want to cancel anything but
    just want to redirect my jsp to another jsp on the click of
    cancel button thats it

  9. #9
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    onclick="document.forms[formName].action='toCancel.jsp';"

  10. #10
    Join Date
    Apr 2008
    Posts
    15
    Hi friends

    Thanks 4 your help
    At last, my problem has been solved
    I used the following code which is working

    <a href="" onclick="javascript:cancelAction();"><input type="button" value="Cancel" name="cancel"></a>


    and the javascript code is

    function cancelAction()
    {
    document.location.href("CardDetailForm.jsp");
    }

    regards,

  11. #11
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The solution is basically flawed as it's using JavaScript.
    You should be detecting the button return value server side and processing the form accordingly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles