Gopi,
Basically we have to create the .class file, create a .jar file which includes this .class file , add this .jar file in classpath, import the .class file in jsp and use it!
Here are the steps.
1. Compile the .java file into .class file in any dir you like
For example : javac JavaRanch.java
2. Create a ABCD.jar file like this in the same dir like foll
This will create a ABCD.jar file in same dir where you executed the command at dos prompt. The
servlet API says ...\webapps\webApplnName\WEB-INF\lib dir is the place where all .jar files should go. So I just moved the ABCD.jar to this dir (..\webapps\webapplName\WEB-INF\lib)
3. Now include this ABCD.jar ( "c:\jakarta-tomcat\webapps\MISAPP\WEB-INF\lib\ABCD.jar" )file in your classpath either by editing c:\autoexec.bat file or some other means.
4. To get the new classpath get into effect just execute c:\autoexec.bat at the command prompt once. Now at command prompt just execute c:\set [ENTER] to see if this ABCD.jar is in classpath setting to make sure.
5. To invoke the class in jsp do this. My sample welcome.jsp file is
6. Save this welcome.jsp as ...\webapps\webApplnName\welcome.jsp
7. stop and restart the server (
tomcat may be)
8. Invoke the jsp from browser like this
http://localhost:8080/WebApplnName/welcome.jsp I tested this and able to invoke the JavaRanch.welcome() method which is in ABCD.jar file from welcome.jsp file and got the
String "Hello Everyone!" displayed in browser. Give it a try!
(careful in typing the webApplnName in
http://localhost:8080/webApplnName/welcome.jsp at the browser because it is case sensitive and your appln Name may be different. If so give your appln name instead.)
regds
maha anna
[This message has been edited by maha anna (edited January 25, 2001).]