单击图像时,我想提交给 servlet1 并确定单击了哪个图像。asnwer 应重定向到 index.jsp 并在“单击状态”后显示。我怎样才能让它在 servlet 端工作?我如何使用 request.getParameter 来确定单击了哪个图像?
index.jsp(部分)
<%
String message = "NoImageWasClicked";
if (session.getAttribute("message") != null) {
message = session.getAttribute("message");
}
%>
<form method="post" action="servlet1">
<input id='img1' type='image' onclick='submit()'/>
<input id='img2' type='image' onclick='submit()'/>
<input id='img2' type='image' onclick='submit()'/>
Clicking status: <%=message%>
</form>
小服务程序1:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.getParameter ( ??????????? )
???????
request.getSession().setAttribute("message", ????????);
response.sendRedirect("index.jsp");
}