在servlet中弹出对话框

来源:互联网 发布:腾讯网络主播怎么赚钱 编辑:程序博客网 时间:2024/05/16 15:20

简单的登录验证模块
点击登录进入相应的Servlet,Servlet调用bean验证用户名是否存在
如果存在则登录成功,跳转
如果不存在则弹出错误对话框,并回到登录页面
开始用的下面两句话
out.print("<script language='javascript'>alert('the name doesnot exit')</script>");
response.sendRedirect("Login.jsp");
但不会显示对话框,而是直接回到Login.jsp
后来改用
JOptionPane.showMessageDialog(null, "name doesnot exits");
response.sendRedirect("Login.jsp");

则可以实现。

 

把response.sendRedirect("Login.jsp");去掉,然后
out.print("<script language='javascript'>alert('the name doesnot exit');window.location.href='Login.jsp';</script>");

原创粉丝点击