我用的是Tomcat 6.0 的,,
在自己写了一个java 类编译了以后运行程序一直出现这样的问题,请各位帮帮忙,小弟初学JSP,,
是不是有可能是环境配置的问题,我运行其他的JSP程序没问题,就一调用自己写的类的时候就出现这样的问题
很急,,在线等待大家,谢谢~!
程序的代码:<%@ page import="umikey.UmiKeyClient" %>
<jsp:useBean id="umi" scope="session" class="UmiKeyClient" />
<%
String umikey = (String)session.getAttribute("umikey");
String pass_word= (String)session.getAttribute("pass_word"); UmiKeyClient umi = new UmiKeyClient(1);
boolean returnver = umi.verify(umikey);错误信息:
org.apache.jasper.JasperException: /check.jsp(23,0) The value for the useBean class attribute UmiKeyClient is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1203)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3365)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
在自己写了一个java 类编译了以后运行程序一直出现这样的问题,请各位帮帮忙,小弟初学JSP,,
是不是有可能是环境配置的问题,我运行其他的JSP程序没问题,就一调用自己写的类的时候就出现这样的问题
很急,,在线等待大家,谢谢~!
程序的代码:<%@ page import="umikey.UmiKeyClient" %>
<jsp:useBean id="umi" scope="session" class="UmiKeyClient" />
<%
String umikey = (String)session.getAttribute("umikey");
String pass_word= (String)session.getAttribute("pass_word"); UmiKeyClient umi = new UmiKeyClient(1);
boolean returnver = umi.verify(umikey);错误信息:
org.apache.jasper.JasperException: /check.jsp(23,0) The value for the useBean class attribute UmiKeyClient is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1203)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3365)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
这句话有问题吧。为什么写个1,我认为就是这个导致了javabean里面属性的值无效
// UmiKey .NET client cliass that calls UmiKey authentication server to
// validate an OTP (One-Time Password) generated by a UmiKey
//
// March 2008
//
// UmiKey.com - the elegant strong authentication built for the webpackage umikey;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;/**
Your app instantiate an object of this class, then call verify(OTP) to validate the
one-time password (OTP) generated by UmiKey
*/public class UmiKeyClient {
// static final String UmiKey_AUTH_SRV_URL = "http://umikey.com/wsapi/verify.php?id=";
static final String UmiKey_AUTH_SRV_URL = "http://localhost/ws/verify.php?id=";
private int _clientId = 1;
private String _response;
/**
* Initializes the UmiKey object.
*
* @param initId The Client ID you wish to verify against or operate within.
*/
public UmiKeyClient(int initId) {
_clientId = initId;
}
public UmiKeyClient( int initId ) {
_clientId = initId;
}
/**
* Returns the ID passed to the initialized UmiKey object.
*
* @return id The Client ID passed to the initializing class.
*/
public int getId() {
return _clientId;
}
public String getLastResponse() {
return _response;
}
public boolean verify( String otp ) { boolean result = false;
_response = "";
try {
URL srv = new URL(UmiKey_AUTH_SRV_URL + _clientId + "&otp=" + otp);
URLConnection conn = srv.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
//System.err.println("Input line=" + inputLine);
_response += inputLine + "\n";
if (inputLine.startsWith("status=")) {
if (inputLine.equals("status=OK")) {
return true;
}
}
}
in.close();
System.err.println("Error response=" + _response);
} catch (Exception e) {
System.err.println("Error! " + e.getMessage());
e.printStackTrace();
} return result;
} // End of verify
public static void main (String args []) throws Exception
{
if (args.length != 2) {
System.err.println("\n*** Test your UmiKey against UmiKey OTP validation server ***");
System.err.println("\nUsage: java com.UmiKey.UmiKeyClient Auth_ID OTP");
System.err.println("\nEg. java com.UmiKey.UmiKeyClient 28 vvfucnlcrrnejlbuthlktguhclhvegbungldcrefbnku");
System.err.println("\nTouch UmiKey to generate the OTP. Visit UmiKey.com for more details.");
return;
}
int authId = Integer.parseInt(args[0]);
String otp = args[1];
UmiKeyClient yc = new UmiKeyClient(authId);
if (yc.verify(otp)) {
System.out.println("\n* OTP verified OK");
} else {
System.out.println("\n* Failed to verify OTP");
}
System.out.println("\n* Last response:\n" + yc.getLastResponse()); } // End of main//get keyid
public String getKeyId(String otp)
{
String keyid = "";
int len = otp.length();
if(len == 48)
{
keyid = otp.substring(4,12);
}
else if(len == 44)
{
keyid = otp.substring(0,12);
}
else if(len == 12)
{
keyid = otp;
}
return keyid;
}
} // End of class
<%@ page import="java.sql.*" %> <html>
<head>
<title>认证码验证页面 </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<style type="text/css">
<!--
body {
background-color: #F0F5F9;
}
-->
</style>
</head>
<body>
<%@ page import="umikey.UmiKeyClient" %>
<jsp:useBean id="umi" scope="session" class="UmiKeyClient" />
<%
String umikey = (String)session.getAttribute("umikey");
String pass_word= (String)session.getAttribute("pass_word"); UmiKeyClient umi = new UmiKeyClient();
boolean returnver = umi.verify(umikey);
if(returnver == true)
{
String keyid = UmiKeyClient.getKeyId(umikey);
//**************************************
// ********* JDBC_ODBC连接MySql数据库,不需要设置数据源
// *********************************
//********** 数据库连接代码 开始 ******/
String server="localhost"; //MYSQL 服务器的地址
String dbname="umi"; //MYSQL 数据库的名字
String user="root"; //MYSQL 数据库的登录用户名
String pass="123456"; //MYSQL 数据库的登录密码
String port="3306"; //SQL Server 服务器的端口号,默认为1433
//数据库连接字符串
String url ="jdbc:mysql://"+server+":"+port+"/"+dbname+"?user="+user+"&password="+pass+"&useUnicode=true&characterEncoding=UTF-8";
//加载驱动程序
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
//建立连接
Connection conn= DriverManager.getConnection(url);
//创建语句对象
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = " select a.UserName as username,a.userid as userid from user a inner join umi b on a.UserId = b.usrid where b.keyid='"+umikey+"' and a.UserPassword ='"+pass_word+"'";
ResultSet rs=stmt.executeQuery(sql);
if (rs.next())
{
out.print("<script type='text/javascript'>alert('登陆成功')</script>");
//提取用户名
session.setAttribute("username",rs.getString("username"));
//获得用户的权限
rs.close();
stmt.close();
conn.close();
%>
欢迎你:
<%=session.getAttribute("username") %> <a href="logout.jsp">注销 </a> <br>
<% }
else
{
out.print("<script type='text/javascript'>alert('登陆失败,用户名或密码错误')</script>");
out.print("<script type='text/javascript'>window.location='index.jsp'</script>");
}
}
else
{
out.print("<script type='text/javascript'>alert('您的Umikey未被激活,请重新换一个Umikey')</script>");
out.print("<script type='text/javascript'>window.location='index.jsp'</script>");
}
%>
</body>
</html>
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.sql.*" %> <html>
<head>
<title>认证码验证页面 </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<style type="text/css">
<!--
body {
background-color: #F0F5F9;
}
-->
</style>
</head>
<body>
<%@ page import="umikey.UmiKeyClient" %>
<jsp:useBean id="umi" scope="session" class="UmiKeyClient" />
<%
String umikey = (String)session.getAttribute("umikey");
String pass_word= (String)session.getAttribute("pass_word"); UmiKeyClient umi = new UmiKeyClient(1);
boolean returnver = umi.verify(umikey);
if(returnver == true)
{
String keyid = UmiKeyClient.getKeyId(umikey);
//**************************************
// ********* JDBC_ODBC连接MySql数据库,不需要设置数据源
// *********************************
//********** 数据库连接代码 开始 ******/
String server="localhost"; //MYSQL 服务器的地址
String dbname="umi"; //MYSQL 数据库的名字
String user="root"; //MYSQL 数据库的登录用户名
String pass="123456"; //MYSQL 数据库的登录密码
String port="3306"; //SQL Server 服务器的端口号,默认为1433
//数据库连接字符串
String url ="jdbc:mysql://"+server+":"+port+"/"+dbname+"?user="+user+"&password="+pass+"&useUnicode=true&characterEncoding=UTF-8";
//加载驱动程序
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
//建立连接
Connection conn= DriverManager.getConnection(url);
//创建语句对象
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = " select a.UserName as username,a.userid as userid from user a inner join umi b on a.UserId = b.usrid where b.keyid='"+umikey+"' and a.UserPassword ='"+pass_word+"'";
ResultSet rs=stmt.executeQuery(sql);
if (rs.next())
{
out.print("<script type='text/javascript'>alert('登陆成功')</script>");
//提取用户名
session.setAttribute("username",rs.getString("username"));
//获得用户的权限
rs.close();
stmt.close();
conn.close();
%>
欢迎你:
<%=session.getAttribute("username") %> <a href="logout.jsp">注销 </a> <br>
<% }
else
{
out.print("<script type='text/javascript'>alert('登陆失败,用户名或密码错误')</script>");
out.print("<script type='text/javascript'>window.location='index.jsp'</script>");
}
}
else
{
out.print("<script type='text/javascript'>alert('您的Umikey未被激活,请重新换一个Umikey')</script>");
out.print("<script type='text/javascript'>window.location='index.jsp'</script>");
}
%>
</body>
</html>
<%
String umikey = (String)session.getAttribute("umikey");
String pass_word= (String)session.getAttribute("pass_word");
在此处打印出来你的umikey 和pass_word,看看对不对。
UmiKeyClient umi = new UmiKeyClient(1);
boolean returnver = umi.verify(umikey);