I have a war file called test.war which contains all my jsp page & web.xml.I have made a jar file called test.jar which contains all my classes. Then I copied these file to tomcat webapps folder.when I start the tomcat. test.war file got unzipped to folder test.Then I put test.jar inside the web-inf of test folder.I changed the web.xml to the following to know my class file
are inside test.jar
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>DBHandler</servlet-name>
<servlet-class>test.jar/Sample.DBHandler</servlet-class> <--- to know where is class
</servlet>
<servlet-mapping>
<servlet-name>DBHandler</servlet-name>
<url-pattern>/DBHandler</url-pattern>
</servlet-mapping>
</web-app>
But when I run the program It is showing error as package name not found. Can anyone tell me what to do.I know this is not the right way, to put my jar inside the web-inf.But I have to put my class files in JAR file only.& and my jsp page & web.xml inside war file.Can anyone tell me what to do.I know I have to modify the web.xml to say all the class r there inside the test.jar.How to do that.
and make sure that u include the jar file inside ur war file so that u do not have to copy it afterwards.
WEB-INF/*.jar
/web.xml
and then servlet mapping if any required inside of the web.xml
Thanks for your replay.I did that. I put test.jar in lib folder of web-inf.
WEB-INF/
/web.xml
/lib/test.jar
But same error is comming as
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:43: package Sample does not exist
Sample.FormBean formHandler = null;
^
An error occurred at line: 4 in the jsp file: /process.jsp
Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:45: package Sample does not exist
formHandler = (Sample.FormBean) pageContext.getAttribute("formHandler", PageContext.REQUEST_SCOPE);
^
Can u tell me what to do.I have put all my classes in test.jar.The jsp is in test.war.When tomcat started. the test.war is unzipping to the test folder .When I looked it has the test.jar in lib dir of web-inf.Do I have to say anything in web.xml to say that classes are there in lib.
Thanks a lot.It worked.When I unzipped the jar file.It comming as
WEB-INF/classes/Sample/DBHandler.class. So I made jar which starts from Package name Sample.Then I put it into lib. import the class name in jsp.then it is working.Thanks for your very fast responses and help once again.
glad to be of a help....:-)
I knew what I had told u to do was correct and u shouldnt have any problem with that...did not know ur jar file had a diff directory structure then what u are trying...heheheh
Bookmarks