JSP调用DLL(jsp引用javabean的问题)
我要用jsp调用dll,方法是把java程序做成bean,代码如下
java 代码 javacall.java
public class javacall {
static
{
System.loadLibrary( "calldll ");
}
public native static int add(int i, int k);
public static void main(String[] args)
{
javacall jc = new javacall();
System.out.println(jc.add(3,4));
}
}
C程序
#include "javacall.h "
JNIEXPORT jint JNICALL Java_javacall_add (JNIEnv *, jclass, jint a,jint b)
{
int j = a*b;
return j;
}
jsp代码 call.jsp
<%@ page contentType= "text/html; charset=GBK " %>
<html>
<head>
<title>
Jsp调用DLL例子
</title>
</head>
<jsp:useBean id= "JBean " scope= "page " class= "javacall " />
<body>
<h1>
<%=JBean.add(3,4)%>
</h1>
</body>
</html>
我使用MYeclipse+tomcat配置的
javacall.class跟call.dll文件存放在C:\Tomcat 6.0\webapps\jspcall\WEB-INF\classes路径下
call.jsp文件在C:\Tomcat 6.0\webapps\jspcall路径下
在浏览器输入http://localhost:8080/jspcall/call.jsp出错
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: 8 in the jsp file: /call.jsp
javacall cannot be resolved to a type
5: Jsp调用DLL例子
6: </title>
7: </head>
8: <jsp:useBean id= "JBean " scope= "page " class= "javacall " />
9: <body>
10: <h1>
11: <%=JBean.add(3,4)%&g