JAVA 代码:
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
String message="error";
session.setAttribute("message",message);
JSP页面:
<%
String str = (String)session.getAttribute("message");
%>
<input type="hidden" name="str" value=<%=str %>>
<script type="text/javascript">
window.document.body.onload = function(){
if((document.getElementById("str").value)=="error"){
alert('用户不存在或密码不正确');
}
}
</script>