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