aspose file tools*
The moose likes Servlets and the fly likes calling funtion by clicking buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling funtion by clicking buttons" Watch "calling funtion by clicking buttons" New topic
Author

calling funtion by clicking buttons

kashif iftikhar
Ranch Hand

Joined: Aug 21, 2001
Posts: 43
i have created a button(Delete).
<input type=button name=del value=delete>
now i want when i click this button the deleteRec() funtion of my utility class called which delete a record from database.and the current page reloaded.
like this..
<% Delete obj = new Delete();
obj.deleteRec(-,-);
%>
how could i do this ?

------------------
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Client and Server side code.
The button gets shown on the client and can only execute client side code (javascript).
The code required to remove a record from the database happens on the server.
What you need to do is have the button (on the server side) send a message (HTTP request) to the server with the details required to perform the db operation then return a response to the client.
Does this clear it up?
Dave.
kashif iftikhar
Ranch Hand

Joined: Aug 21, 2001
Posts: 43
yes , i have done something like this.
1. put a hidden field in the form.
2. when yhe user click the button value set to "delete".
3. and then make a connection to the database.
4. get reference to the EJB Home.
5. call obj.remove() method to remove selected data.


------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling funtion by clicking buttons