my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Where to place - under webapps or ROOT ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Where to place - under webapps or ROOT ?" Watch "Where to place - under webapps or ROOT ?" New topic
Author

Where to place - under webapps or ROOT ?

Reghu Ram Thanumalayan
Ranch Hand

Joined: Oct 21, 2003
Posts: 193
Dear Ranchers,
I am also experiencing the same problem in getting a html page to be displayed in the browser as others had reported in an earlier thread.
I created a directory myapp under tomcat/webapps and had only a html page ( index.htm ) in that directory. But when i access the file with the url - "http://localhost:8080/myapp/index.htm" , the browser throws a 404 - Page not found error. I have made sure that there was no spelling mistakes in the url. Also i dont have any other files or directories under myapp except the index.htm file. But the same setup works when i have myapp under tomcat/ROOT.

I saw kathy replying in the other thread that
you really should put "Beer-v1" inside the webapps directory, not at the tomcat root!


Why is it not a really good idea to place it under ROOT ?

I am able to access the other files like jsp-examples./index.htm which is directly under webapps. How is this possible since I am not able to get my page when it is under webapps directly. What could be the cause ? Am i missing something with the classpath ?

Can some one throw light on how tomcat finds out which page to serve the browser when a request comes in ? I mean how does it know that the myapp/index.htm as in the url above is indeed under webapps only.


Cheers,<br />Reghu Ram T<br /> <br />SCJP 1.4 - 98 %, SCBCD 1.3 - 94 %, SCMAD 1.0 - 92 %
Bahadar Khan
Ranch Hand

Joined: Jun 19, 2003
Posts: 81
If you are following this.

<Tomcat>/<WebApps>/<Your_Web_Application_Direocry>/Your_Index.html, then there can be no reason, why it shouldn't display by calling this URL

http://your_local_host:your_port/Your_Web_Application_Direocry/Your_index.html.

Please double check, if you are doing this? If still you find issue, I would sugegst re-install your tomcat server and do a fresh deployment.
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
Make sure u have WEB-INF/web.xml is the deployed folder (myApp).
Me
Ranch Hand

Joined: Dec 01, 2003
Posts: 51
Reghu do you have

webapps/[YOUR_APPLICATION_NAEM]/WEB-INF/classes directory

and a valid Deployment descriptor
webapps/[YOUR_APPLICATION_NAEM]/WEB-INF/web.xml

In webapps directory, tomcat will not deploy any appliction without a valid deployment descriptor (even if there is a typo in dd, it will not be deployed). I believe if you put in ROOT then it will server the static contents even if it does not have a valid DD.

Look for deployment error messaes when you start up tomcat or to go to
http://localhost:[YOUR_PROT_HERE]/manager/html
and see a list of applicatins deployed succesffuly (You will have to provide username and password for manager role to go to this link)

Hope this helps.
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
Actually, its ok even if you do not have a web.xml file since Tomcat uses its default one. But make sure you add a WEB-INF folder under webapps/Your_application. Otherwise, tomcat will not recognize your application and it will throw a 404 error.


SCJP,SCWCD(1.4)
Reghu Ram Thanumalayan
Ranch Hand

Joined: Oct 21, 2003
Posts: 193
Thank you guys..

After creating a WEB-INF directory under myapp, i am able to get the html page even though there is no web.xml in the WEB-INF.

Can any one provide any links to how actually tomcat is doing all these things in the background. I really like to know how something happens rather that be content with "do like this and it will happen" !
Patrik Nilsson
Ranch Hand

Joined: Oct 05, 2004
Posts: 49
I managed to solve it eventually but there are still a couple of unanswered questions?

If I name the Beer directory Beer or even Beer-v it works but I can't have 2 characters after the - . not Ber-v1
Strange?? I also tried without he WEB-INF dir and it works fine there as well.
Guess I rename my directory instead but it seems very strange.


Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />IBM Certified Enterprise Developer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where to place - under webapps or ROOT ?
 
Similar Threads
Customize 404 errors in Apache Tomcat
page cannot be displayed error
serve static HTML from app context rather than ROOT
can't access tomcat-docs webapp
A Realm for more than one Webapp