Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

navigating to two different pages with two different buttons  RSS feed

 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody.

i want to navigate to two different jsp pages through two different different buttons on the same page.

what is the best way to achieve this.

i have a jsp page





  • i have a jsp page as above
  • i have two buttons whose value are "CREATE" and "Home Page" .
  • here with the click of both "CREATE" and "Home Page" button it should go to a servlet /RequestHandler where after fetching the hidden value specified "25" here it goes to 25th case in that servlet.
  • here i have also called function onSubmitForm(btnValue) , which sets the value of button to a hidden variable userAction
  • ,whichever button is clicked.
  • in Requesthandler servlet on the basis of userAction value ,whether it is Home Page or CREATE it is forwardes to respective page.



  • this the flow of my code.
    Problem but iam not getting forwarded to the respective pages. it remains on the same page after clicking CREATE button or Home Page button.

    can any one please help me where i am going wrong.
  • Also is there any more efficient method to navigate to different pages by clicking different buttons. plase help me.

  • thanks.
     
    amit punekar
    Ranch Hand
    Posts: 544
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,
    First check if you are not getting JavaScript error. I think you must be getting some error.
    Try putting some ALERT in your JS function that would help to determine if that functions gets called when you click on button.
    If that is fine then debug in your servlet to see if any exception has occured.
     
    rammie singh
    Ranch Hand
    Posts: 122
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    see i don't think so that there is any java script error.

    because i tried doing document.drop_list.userAction.value="btnValue";

    here drop_list is form name. but in the sevlet when value of userAction is displayed it gives btnvalue

    i.e the value of clicked button is not being set in variable userAction and hence btnValue is being displayed.

    please give the suggestion.
     
    Balu Sadhasivam
    Ranch Hand
    Posts: 874
    Android Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator


    Amit,



    will actaully set the value to "btnValue" , because it literal and not the variable as passed in the function below.

     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!