tomcat directory structure

[nobr]I tried to create a web application.

I wanted to use a build.xml in which there was a target that copied my war in the webapps directory of Tomcat.

The project structure was

webapplication

web/jsp

web/web-inf

web-inf/src/servlets/Myservlet

My web.xml was:

<!-- we give name hello to our servlet -->

<servlet>

<servlet-name>webapplicationServlet</servlet-name>

<servlet-class>servlets/MainServlet</servlet-class>

</servlet>

<!-- when user provides URL /hello then servlet hello is invoked -->

<servlet-mapping>

<servlet-name>webapplicationServlet</servlet-name>

<url-pattern>/firstPage</url-pattern>

</servlet-mapping>

The problem was that the url

http://localhost/webapplication/firstPage was not working while

the url http://localhost/webapplication/page1.jsp was working

The problem was solved after I removed folder web and inside the webapps of the Tomcat the first folder was WEB-INF

.Does anybody has any idea why this was happening?

It is allowed to place web-inf inside another folder right?

Moreover the source coude of the servlet could be anywhere as long as it is copied afterward in web-inf/classes?

Thanking you in advance.[/nobr]

[1395 byte] By [juanitaJa] at [2007-11-26 13:54:39]
# 1

http://tomcat.apache.org/tomcat-5.5-doc/appdev/deployment.html

1: web-inf needs to capitalized as WEB-INF

2: The compiled class file for MyServlet should be under WEB-INF/classes/servlets

3: The web.xml reference to the MyServlet class file should be:

<servlet-class>servlets.MyServlet</servlet-class>

tolmanka at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

yes I have the web-inf capitalized. But I believe that in the

web.xml we can use the slash syntax

<servlet-class>servlets/MyServlet</servlet-class>

I have use it in the past with success.

Nevertheless thank you for your answer but you haven't replied to the basic one?

It is allowed to place web-inf inside another folder right?such as folder web?

juanitaJa at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Well did you read the tomcat documentation on web application directory structure in the link?
tolmanka at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Yes I've read it and all I am saying is that in previous applications I used the slash syntax and I think it worked.But that is not my problem here.All I am asking is why when I removed the web folder and the root folder below webapps was WEB-INF then the application worked.What was I doing wrong(if it was just the slashes it would not work in any case).

juanitaJa at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

http://www.roguewave.com/support/docs/leif/leif/html/servletug/7-7.html#771

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

http://www.onjava.com/pub/a/onjava/2001/03/15/tomcat.html

http://www.tek271.com/articles/deploying_servlets_on_tomcat.html

http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html?page=4

Every example listed uses a period delimited class name. Not one mentions being able to use a slash deliminted class name.

tolmanka at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Ok I do not disagree but my initial question was if it is ok to use a folder where WEB-INF is stored.Because in my example when I enclosed folder WEB-INF in folder web I had the forementioned problem when I removed folder web and the folder WEB-INF was in the root of the folder webapps of Tomcat things were ok.And so I am asking why this was happening?Forget about the slalshes I accept that slashes is the correct way for web.xml.

juanitaJa at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
The WEB-INF folder has to directly under the web application root directory. Any other WEB-INF folders will be ignored.
tolmanka at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Ok thank you very much for your help.
juanitaJa at 2007-7-8 1:33:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...