Hi Steve
> Could someone/somebody please
> help me out with the whole package structure for tomcat?
Does this help ....?
webapps
|-- ROOT
| |-- WEB-INF
[quoted text clipped - 52 lines]
| `-- welcome.jsp
|-- friendbook-jsp.war
`-- manager.xml
<!-- heavily edited -->
<web-app>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.infohazard.maverick.Dispatcher
</servlet-class>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.m</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
A.
>Could someone/somebody please
>help me out with the whole package structure for tomcat? I would LOVE to
[quoted text clipped - 7 lines]
>
>Can you please help me with this problem? Thanx.
Steve, I think we're confusing packages, webapp names, and directory
trees. Your problem has nothing to do with the Tomcat directory
structure. The "package" part of the directory structure doesn't
start until you get down *below* the \ROOT\WEB-INF\classes folder.
If you want another web application other than the default (ROOT), a
simple way to do it is to create a directory under webapps, e.g.
...\webapps\MyApp\WEB-INF\classes
and then put your classes there. If "MyServlet" looks like this:
package com.steve.myapp;
...
public class MyServlet extends HttpServlet {
...
}
then the class should be located at
...\webapps\MyApp\WEB-INF\classes\com\steve\myapp\MyServlet.class
You then need to tell Tomcat what URL you want to use for the servlet.
The "MyApp" application needs a deployment descriptor (web.xml)
located in it's WEB-INF directory:
...\webapps\MyApp\WEB-INF\web.xml
that contains at least the following:
<?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>MyServlet</servlet-name>
<servlet-class>com.steve.myapp.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
</web-app>
Note that the url pattern is relative to the top of the web
application.
You will then be able to invoke your servlet from
http://localhost:8080/MyApp/MyServlet
(using the appropriate host name and port number, if not 80)
--
Phil Hanna
Author of JSP 2.0: The Complete Reference
http://www.philhanna.com
steve r. burrus - 28 Feb 2004 20:45 GMT
Hi there, phil, this is steve Burrus, and I wanted to first say or tell
u that it is indeed a DISTINCT PRIVILEDGE to be responded back to by
such a "distinguished author" as yourself!! :) So, the main question
that I have for you is : In looking at yer explanation of package
structure, I was just wondering if it's really necessary to create these
3 sub-folders under "...\webapps\MyApp\WEB-INF\classes" as you did :
"com.steve.myapp", and NOT maybe just create only 1 folder, and then
reference that in the package statement thusly : "package [newfolder];"
at the top of my servlet file??? And also, I have for a long time now
wondered about why exactly it's neccessary (or is it?) to create either
a "com" or an "org" folder as the top-level folder under
"WEB-INF\classes"? Okay then, thanx for your time!
***********************************************************************************************
>>Could someone/somebody please
>>help me out with the whole package structure for tomcat? I would LOVE to
[quoted text clipped - 71 lines]
> Author of JSP 2.0: The Complete Reference
> http://www.philhanna.com
Markku - 28 Feb 2004 21:06 GMT
> at the top of my servlet file??? And also, I have for a long time now
> wondered about why exactly it's neccessary (or is it?) to create either
> a "com" or an "org" folder as the top-level folder under
> "WEB-INF\classes"? Okay then, thanx for your time!
That's how the "package" system works in Java.
Package "com.myclasses" includes some classes and
files are in the folder ../com/myclasses/
And why it is so? If you got two (or more) classes with
same name like java.sql.Date and java.util.Date
you can't put them in the same folder can you?

Signature
Markku