我写了一个HTML和一个JSP文件用来检测登陆密码是不是合法。可是在登陆的时候,不管密码如何,都会提示合法(welcome)和不合法(your password is not pass)两中情况。
另外单独编译JSP文件的时候,也报错:
An error occurred at line: 36 in the jsp file: /login.jsp
Generated servlet error:
D:\workspace\project\work\org\apache\jsp\login_jsp.java:81: "else" 不带有 "if"
};else{
^
1 错误
检查很九不知道为什么,哪位能告诉我啊
HTML文件:
<html>
<head><title>Login</title></head>
<body>
<form action=login.jsp method=post>
<p>UseName:<input type=text name=inputname>
<p>PassWord:<input type=password name=inputpassword>
<p><input type=submit value=Sumbit>
</form>
</body>
</html>
JSP文件:
<%@page import="java.lang.*"%>
<html>
<head><title>The Login Page</title></head>
<body>
<%!final static int Min_Pass=6;
final static int Max_Pass=14;
public boolean verifyPasswordLength( String password )
{
if(( password.length()<=Max_Pass)&&(password.length()>=Min_Pass))
return true;
else return false;
}
public boolean verifyPasswordHasDigit( String password )
{
int i=0;
for( int j=0;j<password.length();j++)
{
if( Character.isDigit(password.charAt(j) ) )
i++;
}
if ( i>0 ) return true;
else return false;
}
public boolean verifyPasswordPollcy( String password )
{
if( ( verifyPasswordLength( password ))&&(verifyPasswordHasDigit(password)))
return true;
else return false;
}%>
<% String password=request.getParameter( "inputpassword" ) ;
if( verifyPasswordHasDigit( password ) )%>
<p> Welcome!
<%;else{%>
<p>Sorry! Your Password Is not Pass.
<p><a href="login.html">Plaese Try Again</a>
<%}%>
</body>
</html>
[此贴子已经被作者于2006-4-7 19:11:51编辑过]