0

I have a jsp page that contain a button when the user click on the button i want to display a text so any idea how to handle the onClick event from JSP

Thank you in advance

Amira Manai
  • 2,599
  • 8
  • 40
  • 60

2 Answers2

0

You can do this

<div id='myDiv'></div>

<input id='myButton' type='button' value='My Button' />

<script type="text/javascript">
$('#myButton').click(function()
{

$("#myDiv").html("The text that you want to display");
});
</script>
Uchenna Nwanyanwu
  • 3,174
  • 3
  • 35
  • 59
0

There is no such event system in servlet/JSP. In fact you may pass key-value pair data along with the servlet request.

sample.jsp

<form method="post" action="servlet_url">
  <input type="submit" name="cmd" value="Add"/>
  <input type="submit" name="cmd" value="Delete"/>
</form>

and code in doPost of servlet

String cmd=request.getParameter("cmd");
if(cmd.equals("Add"))
  {
   //
  }
else
if(cmd.equals("Delete"))
 {
 //
 }
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186