Reputation: 625
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.
Upvotes: 2
Views: 9769
Reputation: 1825
firstly place your external .jar to the lib folder of your application (WEB-INF/lib) then simply you have to import that class or package of the jar file which you want to use by using import tag of the jsp.
<%@ page import="yourPackage.ClassName" %>
and now you can simply call your method on the object of that class as you do in simple java program
Upvotes: 0
Reputation: 94645
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.
If that type XXXX
is public
and
XXXX.executeQuery(param)
syntax;public
instance method then create an object of XXXX
type and call it.Upvotes: 2
Reputation: 3676
Why import a separate jar file to perform this you should use
Upvotes: 1
Reputation:
You shouldn't do that in a JSP (presentation layer), but if you really want that you have to import the class/classes with the following line in JSP:
<%@ page import="package1.myClass1,package2.myClass2,....,packageN.myClassN" %>
Upvotes: 0