Javascript 如何在单击html表单的不同按钮时调用不同的servlet
我有一个html表单,我想在单击两个不同的按钮时调用两个不同的servlet如何更改表单操作运行时Javascript 如何在单击html表单的不同按钮时调用不同的servlet,javascript,html,servlets,Javascript,Html,Servlets,我有一个html表单,我想在单击两个不同的按钮时调用两个不同的servlet如何更改表单操作运行时 <form> <input type="submit" value="Question Paper" style="height:25px; width:120px; background-color: royalblue;color: white;" /> <input type="submit" value="Instruction" style="height:
<form>
<input type="submit" value="Question Paper" style="height:25px; width:120px; background-color: royalblue;color: white;" />
<input type="submit" value="Instruction" style="height:25px; width:120px; background-color: royalblue;color: white;" />");
</form>
");
单击按钮后,我想在每个按钮上调用servlet1和servlet2
请帮我解决这个问题,提前谢谢有几种方法可以实现这一点 可能最简单的方法是使用JavaScript更改表单的操作
<input type="submit" value="SecondServlet" onclick="form.action='SecondServlet';">
<form action="FirstServlet" method="Post">
Last Name: <input type="text" name="lastName" size="20">
<br><br>
<input type="submit" value="FirstServlet">
</form>
<form action="SecondServlet" method="Post">
<input type="submit"value="SecondServlet">
</form>
<form action="MainServlet" method="Post">
Last Name: <input type="text" name="lastName" size="20">
<br><br>
<input type="submit" name="action" value="FirstServlet">
<input type="submit" name="action" value="SecondServlet">
</form>
String action = request.getParameter("action");
if ("FirstServlet".equals(action)) {
// Invoke FirstServlet's job here.
} else if ("SecondServlet".equals(action)) {
// Invoke SecondServlet's job here.
}