我想在每次单击按钮时运行不同的servlet,但是我不知道该怎么做?有什么主意吗?
<form action="MainServlet" method="Post">
SOME Name: <input type="text" name="someName" size="20">
<br><br>
<input type="submit" name="first" value="FirstServlet">
<input type="submit" name="second" value="SecondServlet">
<input type="submit" name="third" value="ThirdServlet">
<input type="submit" name="fourth" value="FourthServlet">
</form>
with the following in MainServlet
String sometext = request.getParameter("someName"); // your text box value
if (request.getParameter("first") != null) {
// Invoke FirstServlet's job here.
} else if (request.getParameter("second") != null) {
// Invoke SecondServlet's job here.
} else if (request.getParameter("third") != null) {
// Invoke ThirdServlet's job here.
} else if (request.getParameter("fourth") != null) {
// Invoke FourthServlet's job here.
}