当前位置: 代码迷 >> Java Web开发 >> 我这个JPS程序运行的时候弹出一个错误
  详细解决方案

我这个JPS程序运行的时候弹出一个错误

热度:261   发布时间:2007-08-21 17:07:44.0
我这个JPS程序运行的时候弹出一个错误
我写了一登录验证的程序,第一个是保存为login
<html>
<head>
<title>A simple login Page</title>
</head>
<body>
<p>Please Login
<form action=login.jsp method=post>
<p>user name:<input type=text name=usenameField>
<p>password:<input type=text name=passwordField>
<p><input type=submit value=submit>
</form>
</body>
</html>
第二个保存为login.jsp
<
html>
<head>
<title>A simple JSP That verifies Password Policy</title>
</head>
<body>
<%! final static int MIN_PSWD_LEN=8;
boolen verifyPasswordLength(String password){
if(password.length()<MIN_PSWD_LEN)return false;
return true;}
boolen verifyPasswordHasDigit(String password){
for(int i=0;i<password.length();i++)
if(Character.isDigit(password.CharAt(i))) return true;
return false;}
boolen verifyPasswordPolicy(String password){
if(verifyPasswordLength(password)&&verifyPasswordHasDigit(password))
return true;
return false;
}
%>
<% String password=request.getParameter("passwordField");
if(verifyPasswordPolicy(password)){%>
<p> thankyou
<p>Your password meets the security policy
<%}else{%>
<p>Sorry
<p>Your password does not meet the security policy
<p><A haef="login">Please try again</a>
<%}%>
</body>
</html>
但是我登录login输入用户名和密码之后弹出了

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /login.jsp

Generated servlet error:
    [javac] Compiling 1 source file

D:\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\login_jsp.java:11: ?????
??? ? boolen
??? ? org.apache.jsp.login_jsp
    boolen verifyPasswordLength(String password){
    ^



An error occurred at line: 6 in the jsp file: /login.jsp

Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\login_jsp.java:14: ?????
??? ? boolen
??? ? org.apache.jsp.login_jsp
    boolen verifyPasswordHasDigit(String password){
    ^



An error occurred at line: 6 in the jsp file: /login.jsp

Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\login_jsp.java:18: ?????
??? ? boolen
??? ? org.apache.jsp.login_jsp
    boolen verifyPasswordPolicy(String password){
    ^



An error occurred at line: 6 in the jsp file: /login.jsp

Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\login_jsp.java:16: ?????
??? ?? CharAt(int)
??? ? java.lang.String
     if(Character.isDigit(password.CharAt(i))) return true;
                                  ^
4 ??


    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

我不知道是怎么回事啊.哪为大哥教教我
搜索更多相关主题的帖子: login  JPS  input  name  

----------------解决方案--------------------------------------------------------
你是直接把html改为jsp文件的么
html改为jsp时需要把JSP的代码加上去的
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
加上<html>标记上面即可
你加了么?

----------------解决方案--------------------------------------------------------
把login.jsp文件中第6行的感叹号去掉试试?
----------------解决方案--------------------------------------------------------
[QUOTE]
html>
<head>
<title>A simple JSP That verifies Password Policy</title>
</head>
<body>
<%! final static int MIN_PSWD_LEN=8;
boolen verifyPasswordLength(String password){
if(password.length()<MIN_PSWD_LEN)return false;
return true;}
boolen verifyPasswordHasDigit(String password){ //应该是boolean
for(int i=0;i<password.length();i++)
if(Character.isDigit(password.CharAt(i))) return true;
return false;}
boolen verifyPasswordPolicy(String password){
if(verifyPasswordLength(password)&&verifyPasswordHasDigit(password))
return true;
return false;
}
%>
<% String password=request.getParameter("passwordField");
if(verifyPasswordPolicy(password)){%>
<p> thankyou
<p>Your password meets the security policy
<%}else{%>
<p>Sorry
<p>Your password does not meet the security policy
<p><A haef="login">Please try again</a>
<%}%>
</body>
</html>[/QUOTE]
注意看出错提示!!!!
----------------解决方案--------------------------------------------------------
你那11行的for循环没写大括号吧?
----------------解决方案--------------------------------------------------------
楼上的小妹妹,那里本来就不该有大括号
----------------解决方案--------------------------------------------------------
boolen verifyPasswordLength(String password){

----------------解决方案--------------------------------------------------------
我已经搞定了.是有几个大小写的问题
----------------解决方案--------------------------------------------------------
  相关解决方案