Take the 2-minute tour ×
 public void display()  

<input type="submit" value="touch me" method="display()"/>

I have a jsp page like above. How can i call a method when the user clicking the button.The above code is not working. How i do it without javascript...

share|improve this question

1 Answer 1

You are confusing server side and client side. The code is generated on the server side, your user clicks on the client side. If you want to call server side code from the client side you need to look into ajax.
If you want to carry out events on the client side you need to use javascript

<script type="text/javascript>
 function alert() {
<input type="submit" value="touch me" onClick="alert();"/>
share|improve this answer
thanks morris... Eventhough is anyother way to do the same thing in JSP? –  Pearl Feb 16 '13 at 10:57
as I said your JSP runs on the server side, it is compiled and sent via the internet to the client side. So the user clicks on the button in their browser. If you want that click to do something synchronously then you can submit a form, if you want it to do something asynchronously then you need to use ajax. –  Boris the Spider Feb 16 '13 at 11:12
k.I will make the same thing in ajax... –  Pearl Feb 16 '13 at 12:01

Your Answer


