• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where to place - under webapps or ROOT ?

 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure u have WEB-INF/web.xml is the deployed folder (myApp).
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Reghu Ram Thanumalayan
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" !
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic