Everything worked fine until I needed to use jar (inside WEB-INF>lib) file instead of classes in my WEB-INF. I have no idea how the html page calls the servlet from this jar file.
Do I need to add something to my web.ini file? please help.
I used Eclipse to make a jar file, where i checked only 开发者_开发技巧build. Is it correct?
My servlet.class location inside build is
com.servlets.getData.class
Here is my web.ini
<display-name>crudoperation</display-name>
<servlet>
<description>
</description>
<display-name>upload</display-name>
<servlet-name>upload</servlet-name>
<servlet-class>com.servlets.getData</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>upload</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
@Harry: You are right. The method that i am using is absolutely correct. I'll explain the problem that I was facing.
In my WEB-INF>classes
i have this structure com>servlets>getData.class
which works fine. But once I export my project builds into a jar and place it inside {myproj}>WEB-INF>lib
folder I was renaming 'com>servlets' to servlets1 (assuming now the web.ini will not be able to call getData from classes folder) this was the mistake, because it was able to look for com
but then no servlets
and i think it was totally ignoring my jar in lib folder.
So I totally removed my classes folder and now it works perfectly.
精彩评论