【发布时间】:2019-11-11 00:34:14
【问题描述】:
用户向servlet发送请求,servlet向jsp返回响应, 我还想在 servlet 响应 jsp 后在 jsp 上显示 alert("message"), 我应该怎么做?请帮帮我,谢谢。
<FORM method="post" action="/test/Application.do">
<input type="submit" value="cancel" onclick="return confirm('sure?')"/>
<input type="hidden" name="action" value="cancelApp"/>
</FORM>
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
res.setContentType("text/html; charset=UTF-8");
String action = req.getParameter("action");
if (action.equals("cancelApp")) {
//to something with database
String url = "/front-end/Application_Topping_MainPage.jsp";
RequestDispatcher dispatcher = req.getRequestDispatcher(url);
dispatcher.forward(req, res);
return;
}
【问题讨论】:
标签: javascript jsp servlets