Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:15:24+00:00 2026-06-16T04:15:24+00:00

I am developing a web application using JSP and Servlets. I wants to call

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:15:25+00:00Added an answer on June 16, 2026 at 4:15 am

    You should specify the action on the form itself not the actual input button.

    If you define an action on the form. E.g.

    The forms submit button will submit the form to that URL. E.g.

    <form action="/mypath/someurl">
        <input type="submit" value="Submit" />
    </form>
    

    You can add an additional attribute to the form tag to specify whether you want the request to be a get or a post.

    <form action="/mypath/someurl" method="POST">
    

    Would send a post request, you can then pick this up in your Servlet with the handlePost method

    The above approach should be used, currently you are trying to call a Java method on a javascript onclick event. This is incorrect and it is not doing what you think it is.

    The code in PlanProtocolEdit. Update should be in a doGet or doPost method of a servlet which will be triggered by configuring your form as described above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application using JSP and Servlets. In that application I
I am developing a web application using JSP and Servlet. I am trying to
I am developing a web application using JSP & Servlet.(IDE: Eclipse, Container: Tomcat7.0) To
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I'm developing a web application using c# to send and receive SMS from GSM
I'm developing a java servlet web application that manages information from multiple databases (all
I am developing a dynamic JSP/Servlet web application. In order to handle the session,
We are developing a web application using php/java servlets. i would like to pass
I am developing a web application using Java/JSP. One class, say Student, has a
Here is the scenario: I am developing a web application written in servlet JSP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.