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)%>
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)%>
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)%>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
不知道怎么回事啊,谢谢了
[解决办法]
调用javabean端口冲突,dll文件路径不对
注意tomcat启动时的java.library.path路径
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html