I am developing a web application using JSP and Servlets.
I wants to call servlet's method from JSP page when user click's on the Update button.
<input type="button" value="Update" onclick="<%MyServletName.Update(request, response);%>"></input>
When I click on Update button then this method is calling the servlet, But the problem is that when form is loaded then this method is called automatically.
Thanks in advance.....
Source Code....
<%@page import="MyPackageName.MyServletName"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Update</title>
</head>
<body>
<form>
<%
String[][] data = (String[][])request.getAttribute("data");
String[] columnNames = (String[])request.getAttribute("columnNames");
//fill the table data
if(columnNames.length!=0 && data.length!=0)
{
%><table><%
}
for(int i=0;i<data.length;i++){
%>
<tr> <td><%= columnNames[0] %></td> <td><input type="text" name="text1" value="<%= data[i][0] %>"></td> </tr>
<tr> <td><%= columnNames[1] %></td> <td><input type="text" name="text2" value="<%= data[i][1] %>"></td> </tr>
<tr> <td><%= columnNames[2] %></td> <td><input type="text" name="text3" value="<%= data[i][2] %>"></td> </tr>
<%
}
%>
<tr>
<td></td>
<td><input type="button" value="Update" onclick="<%PlanProtocolEdit.Update(request, response);%>"></input></td>
</tr>
</table>
</form>
</body>
</html>
Is there any way that I can call the servlet method other than dogGet() and doPost() without invoking the servlets dogGet() and doPost() methods?