aspose file tools*
The moose likes Servlets and the fly likes where to keep .jar file that is called in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to keep .jar file that is called in jsp page" Watch "where to keep .jar file that is called in jsp page" New topic
Author

where to keep .jar file that is called in jsp page

Gopi Krishna
Greenhorn

Joined: Jan 25, 2001
Posts: 10
Hi,
I am importing a package in my jsp page. All imported packages are in a jar file. Where should I place this jar file inorder to view by my jsp page.
Thanks for your valuable time
Gopi
Mahesh Eshwarappa
Greenhorn

Joined: Jan 04, 2001
Posts: 28

In the properties file of the JSP server u can mention the classpath for the jar files which u will be using. You can type the location of u r jar file in the classpath.
Mahesh
Originally posted by Gopi Krishna:
Hi,
I am importing a package in my jsp page. All imported packages are in a jar file. Where should I place this jar file inorder to view by my jsp page.
Thanks for your valuable time
Gopi

Gopi Krishna
Greenhorn

Joined: Jan 25, 2001
Posts: 10
Hi
I am a bit hasty in posting my question.
Here are details. I am using Weblogic 5.1.
and in my "myjsp.jsp" page I refer to classes of package
<%@ import page="com.xyz.abc" %>
and all classes of com.xyz.abc package are in a jar file ABCD.jar file.
Where should I place this ABCD.jar file so that myjsp.jsp page can see them.
Thanks Mahesh.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
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).]
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
I used Weblogic for last project, somehow its jsp compiler can not find jar file even though you put it on the classpath. In the weblogic.properties file, here is the line I did:
weblogic.httpd.servlet.classpath=E:/weblogic/myserver/servletclasses;\
E:/weblogic/myserver/servletclasses/jaxp.jar;\
E:/weblogic/myserver/servletclasses/parser.jar;\
E:/weblogic/myserver/servletclasses/xml.jar;\
E:/weblogic/myserver/servletclasses/mail.jar;\
E:/weblogic/myserver/servletclasses/providerutil.jar
weblogic.httpd.servlet.reloadCheckSecs=1
However, that does not work for jsp. I searched for a while, and no one seems to have the answer, so finally what I did was unjar the file into E:/weblogic/myserver/servletclasses.
Have you ever thinking about doing a WAR instead of jar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where to keep .jar file that is called in jsp page