如何从JSP中的jar文件中调用方法? [英] How to call method from jar file in JSP?
问题描述
我具有Java程序,因为我具有数据库连接性,并且很少有调用方法来运行SQL查询.我使用Apache ANT为该Java文件生成了jar文件.
现在,我将该jar文件导入了我的JSP.现在如何从该Java文件中存在的jar文件中调用方法executeQuery(String sql)
.
I have Java program in that I have database connectivity, and few methods to be call to run SQL query. I generated jar file for that java file using Apache ANT.
now I imported that jar file in my JSP. now how to call method executeQuery(String sql)
from that jar file which is present in that Java file.
推荐答案
为了在您的Web应用程序中使用外部.jars
,必须将这些JARs
放在WEB-INF/lib
文件夹下,并且您要调用方法-<在XXXXX
类中定义的c0>.
In order to use external .jars
in your webapp, these JARs
must be placed under WEB-INF/lib
folder and you want to call a method - executeQuery(String sql)
defined in XXXXX
class.
如果该类型XXXX
是public
和
- 方法executeQuery(String sql)是公共静态的,然后通过
调用此方法XXXX.executeQuery(param)
语法; - 如果它是
public
实例方法,则创建一个XXXX
类型的对象并调用它.
- Method executeQuery(String sql) is public static then call this method via
XXXX.executeQuery(param)
syntax; - If it is an
public
instance method then create an object ofXXXX
type and call it.
这篇关于如何从JSP中的jar文件中调用方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!