(1)
response.setContentType("text/html;charset=utf-8");
PrintWriter writer=response.getWriter();
writer.println("<script>alert('用户名或密码不正确!');window.location.href='adminlogin.jsp';</script>");
(2)
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("<script language='javascript'>alert('操作失败!');" +"window.location.href='"+request.getContextPath()+"/admin/addprice.jsp?id="+id+"';</script>");
这两个都可以在浏览器上成功运行出来,但是由于由于IE与火狐的兼容性问题,有的方法并不能运行出来,总之两个都试试吧