Accessing Servlets In Packages

2000-11-16 Thread JTBldrCO

I seem to have my problem solved, but let me get this back on the mailing 
list for the benefit of the archives --

I was having trouble accessing servlets that reside in my own packages.  My 
test cases could access .class files in:
 
/usr/local/jakarta-tomcat/webapps/myWebApp/WEB-INF/classes
 
For example "SnoopServlet.class" in that subdir is accessed with:
 
http://www.mySiteName.com/myWebApp/servlet/SnoopServlet
 
Now, take a class, SomePackageClass, declared to be in package testapackage 
within its .java code file.  Its compiled form is in the following file:
 
/usr/local/jakarta-tomcat/webapps/myWebApp/WEB-INF/classes/testapackage/SomePa

ckageClass.class
 
I would like to (but CANNOT) access it with:
 
http://www.mySiteName.com/myWebApp/servlet/testapackage/SomePackageClass
 
INSTEAD, I FIND I MUST USE:

http://www.mySiteName.com/myWebApp/servlet/testapackage.SomePackageClass
 
(Note the "." notation separating the package name and class name, rather 
than a "/".)

Unfortunately, the slash notation worked with JServ, for which I have tons of 
working code, but not with Tomcat.

Thanks for others' comments related to possible addition of servlet tags in 
file /webapps/myWebApp/WEB-INF/web.xml but it looks like I'd still have 
to change all my JServ code (the calling HTML) that used the slash notation. 

Incidentally, I found a sprinkling of material pertaining to my problem in 
the new book "Core Servlets and JavaServer Pages" by Marty Hall.  This was 
published this year (year 2000) for Sun Microsystems by Prentice Hall (see 
pages 30-42).  I wish to give them a plug for this very current effort 
complete with some updates based on Tomcat 3.1.  Price is US$42.99.

John Thompson
Boulder, Colorado, USA
[EMAIL PROTECTED]




Re: Accessing Servlets In Packages

2000-11-16 Thread Craig R. McClanahan

[EMAIL PROTECTED] wrote:

 [snip]
 Now, take a class, SomePackageClass, declared to be in package testapackage
 within its .java code file.  Its compiled form is in the following file:

 /usr/local/jakarta-tomcat/webapps/myWebApp/WEB-INF/classes/testapackage/SomePa

 ckageClass.class

 I would like to (but CANNOT) access it with:

 http://www.mySiteName.com/myWebApp/servlet/testapackage/SomePackageClass


Why can't you use a servlet definition and mapping like this:

servlet
servlet-nameMy Servlet/servlet-name
servlet-classtestpackage.SomePackageClass/servlet-class
/servlet

servlet-mapping
servlet-nameMy Servlet/servlet-name
url-pattern/servlet/testpackage/SomePackageClass/url-pattern
/servlet-mapping

which would support your desired URL?


 John Thompson
 Boulder, Colorado, USA
 [EMAIL PROTECTED]

Craig McClanahan