I think you forgot the web.xml file which contains the mapping between the
URL and the servlet class file.
In web.xml which must be situated in WEB-INF directory, for each servlet
there must be a servlet-mapping entry:
<servlet>
  <servlet-name>MyServlet</servlet-name>
 
<servlet-class>subdirectory1.subdirectory2.subdirectory3.servlet1.class</ser
vlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>MyServlet</servlet-name>
  <url-pattern>/doMyServlet</url-pattern>
</servlet-mapping> 

Now calling http://localhost:8080/MyWebapp/doMyServlet will start the
servlet1.class.
Maybe you should read some documentation about a .war file (which is a
.jar), or open one of the examples delivered together with Tomcat.

-----Original Message-----
From: Cressatti, Dominique [mailto:[EMAIL PROTECTED]]
Sent: donderdag 17 januari 2002 11:06
To: Tomcat Users List
Subject: executing servlet in a jar file


Hi,
 
am trying to execute a servlet within a jar file.
I gathered so far that I had to copy the jar file in ./WEB-INF/lib
 
As an alternative I've extracted the content of that jar file an
put the classes under ./WEB-INF/classes.
The problem is that the servlet I want to execute is buried within
several subdirectories and when extracted it looked like something like:
 
MyWebapp/subdirectory1/subdirectory2/subdirectory3/servlet1.class
 
Like I said I copied all the servlets under /subdirectory3 into
./WEB-INF/classes
but when tried to run it manually (
http://localhost:8080/MyWebapp/servlet/servlet1)
it can up with a error mentioning the above directory structure so I
gathered
the servlets object to move out the directory structure.
I then moved all the above directory structure back (including moving back
the servlets under
/directory3) under ./WEB-INF/classes but when I tried to run again it just
wouldn't find my
servlet (resource ....is not available).
 
So how do I run the servlet manually ((like
http://localhost:8080/MyWebapp/servlet/servlet1)
using the jar file or how organise my directories so my servlet work when
extracted under ./WEB-INF/classes ?

 
Thanks
Dom

 

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to