• 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

how to expose defined directory under webapps

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Guru,
I just installed tomcat. How do I make my hello.html under a directory my_dir visible to the web? Thanks.
tomcat\webapps\ROOT
\my_dir\hello.html
John
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<tomcat-root>\webapps\yourApp\my_dir\hello.html


The above deployment is better, coz you just don't need to mess up with the default web application of Tomcat in the future development as well...
But your deployment is also alright... What problem are you facing now?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like the problem you are having is that you're trying to view the file in the ROOT web app, but you are placing the file in a sub-directory. It's been a while since I used Tomcat, but I believe it treats this as a web-context ie a web app different to the one you've specified.
Try placing the file in the tomcat\webapps\ROOT directory and verify that you can load it as localhost/hello.html
To expand on the problem, servlet containers are designed to serve multiple separate 'applications' at the same time, and keeps them separate by giving them a named 'context'. Usually the behaviour is that the first part of the request is the context. Therefore http://localhost/app1/hello.html loads hello.html from the app1 context and http://localhost/app2/hello.html loads hello.html from the app2 context.
Then there is a special context that has no name and is a convenient place to drop your application,s but sometimes nested directories get treated like contexts, and I believe this is the behaviour you are seeing.
As I said, try dropping the file in the root directory and see if it works. Someone with more specific Tomcat knowledge may be able to provide a work-around.
Dave
 
Author
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have probably already done it. If you put my_dir in the webapps/ROOT directory, you should be able to see hello.html by going to http://127.0.0.1/my_dir/hello.html or if you haven't changed Tomcat's default port, the page would appear on http://127.0.0.1:8080/my_dir/hello.html -- also make sure Tomcat is on!
As was mentioned above, usually you don't want to put things on the web this way. Usually you make a whole "web application" that you have Tomcat map to a URL, e.g. http://www.yourserver.com/foo or http://www.yourserver.com/, etc). There are of course lots of benefits to making your own web application instead of placing directories in webapps/ROOT, but that is something to worry about another day.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayson Falkner:
There are of course lots of benefits to making your own web application instead of placing directories in webapps/ROOT, but that is something to worry about another day.


That's what I have mentioned before...
Deployment in Tomcat is not that difficult, as we might expect. But sometimes we will mess them up, if we do not carefully maintain the proper structure of Tomcat... Here is the link to the doing basic things with Tomcat by Mr.Kevin... U might want to have a look on it....
http://kevinj.develop.com/javahome/javatomcat.jsp
John McDonald, hope your testing works well....
[ January 27, 2004: Message edited by: Ko Ko Naing ]
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic