Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

tomcat directory structure

843841Jan 2 2007 — edited Jan 3 2007
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 <br>
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.

Comments

843841
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>
843841
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?
843841
Well did you read the tomcat documentation on web application directory structure in the link?
843841
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).
843841
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.
843841
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.
843841
The WEB-INF folder has to directly under the web application root directory. Any other WEB-INF folders will be ignored.
843841
Ok thank you very much for your help.
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 31 2007
Added on Jan 2 2007
8 comments
187 views