0
 <input type="button" value="Refer Candidate" class="formbtn" data-toggle="modal" data-target="#recruiterModal">

I want to call a jsp page through a button click using jquery.

Rabindra
  • 101
  • 1
  • 4
  • 13
  • what call would you like to make? – Pragun Nov 04 '16 at 04:38
  • i want to open a jsp page through button click. Any help will be appreciated. – Rabindra Nov 04 '16 at 04:43
  • Why not just use an anchor (a) and style it how you want? That's what they are designed for. – Robbie Nov 04 '16 at 05:50
  • 1
    Possible duplicate of [How to make a button redirect to another page using jQuery or just Javascript](http://stackoverflow.com/questions/2238368/how-to-make-a-button-redirect-to-another-page-using-jquery-or-just-javascript) – Robbie Nov 04 '16 at 05:50

3 Answers3

0

You can use a form tag which wraps the input tag with type=submit and in the form's action attribute you can specify the JSP page's link.

<form action='jsp-page-to-call.jsp'>
  <input type="submit" value="Refer Candidate" class="formbtn" data-toggle="modal" data-target="#recruiterModal">
</form>

So on click of the Submit Button the request goes to the JSP Page.

0

Using JS

    <form id="frmID">
      <input type="submit" value="Refer Candidate" class="formbtn" data-toggle="modal" data-target="#recruiterModal">
    </form>

   On button click
document.getElementById("frmID").action="${pageContext.request.contextPath}/YourjspPage.jsp";
document.getElementById("frmID").submit();
Pawan Lakhara
  • 1,146
  • 4
  • 16
  • 28
0
<input id="buttonid" type="button" value="Refer Candidate" class="formbtn" data-toggle="modal" data-target="#recruiterModal">

   $('#buttonid').click(function(){
      window.open('yourJspPageHere.jsp','_blank');
   });

is this what you're looking for?

Pragun
  • 1,123
  • 8
  • 20
  • where to place the above jquery code as my button is inside the
    . The code is displaying in jsp page accordingly wherever i am pasting it.
    – Rabindra Nov 04 '16 at 05:13
  • do u have a separate js file? this is probably a bad practice but as i've no idea about your application structure, you can place the code after the inside tags – Pragun Nov 04 '16 at 05:15
  • thanks Pragun for all your help. it's working now but while clicking on button getting 404 error as requested resource not available. Any help?? – Rabindra Nov 04 '16 at 05:20
  • thats because you've to specify the location of your jsp page. – Pragun Nov 04 '16 at 05:22
  • where to specify the location as both the jsp pages are located in the same location. – Rabindra Nov 04 '16 at 05:30
  • window.open('./yourJspPageNameHere.jsp','_blank'); try this – Pragun Nov 04 '16 at 05:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/127343/discussion-between-rabindra-and-pragun). – Rabindra Nov 04 '16 at 06:03