参考链接1:https://blog.youkuaiyun.com/zhouzhiwengang/article/details/44924795?utm_source=blogxgwz1
参考链接2:http://blog.sina.com.cn/s/blog_6b3f93bd0100w0hm.html
第一种方法:用swing的对话框
JOptionPane.showMessageDialog(null, "输入有误请重新输入");
response.sendRedirect("index.jsp");
第二种方法:重定向时传递错误的信息的参数,并在所传递页面用js判断一下
Servlet:
response.sendRedirect("index.jsp?error=yes");
index.jsp:在最后</html>标签后写
<script>
var errori ='<%=request.getParameter("error")%>'
if(errori=='yes'){
alert("输入有误!");
}
</script>