(Non-original)
Way 1:jsp Front End
<script type= "Text/javascript" language= "JavaScript" >
Alert ("You are not logged in, please log in ...");
Window.document.location.href= "userlogin.html";
</script>
Way 2:java Backstage
public void Popalert () {
Response.setcharacterencoding ("Utf-8");
PrintWriter out = Response.getwriter ();
Out.print ("<script>alert (' You are not logged in, please login ... '); window.location= ' userlogin.html ' </script> ');
Out.flush ();
Out.close ();
}
Way 3:java Backstage + JSP frontend
1) Java Background Code snippet
public void Popalert () {
Request.setattribute ("LoginError", "You are not logged in, please login ..."); Setting Error Properties
Request.getrequestdispatcher ("userlogin.html"). Forward (request, response);
}
2) JSP frontend code snippet
<%
String errorinfo = (string) request.getattribute ("LoginError"); Get Error properties
if (errorinfo! = null) {
%>
<script type= "Text/javascript" language= "JavaScript" >
Alert ("<%=errorInfo%>"); Pop-up error message
window.location= ' userlogin.html '; Jump to login screen
</script>
<%
}
%>
Summarize
Three ways, essentially through the JavaScript popup dialog box, prompting the user password error, when the user clicked the Alert OK button, automatically jump to the login interface userlogin.html