Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

tomcat context

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i like to access my index.xml file placed in /root/apache-tomcat-7.0.61/webapps/u/ROOT/index.xml using the context.
if i put the context inside the server.xml everything is fine: http://vucni66.localdomain:8080/u/ or http://vucni66.localdomain:8080/v/
if i put u.xml like /root/apache-tomcat-7.0.61/conf/Catalina/vucni66.localdomain/u.xml or /root/apache-tomcat-7.0.61/webapps/u/META-INF/u.xml then does not works.Please why?


outpput of u.xml:
/root/apache-tomcat-7.0.61/webapps/u/ROOT/index.xml
</Context>

output of server.xml:
<Host name="vucni66.localdomain" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<Context path="/u" docBase="/root/apache-tomcat-7.0.61/webapps/u/ROOT" />
<Context path="/v" docBase="/root/apache-tomcat-7.0.61/webapps/v/ROOT" />
</Context>

</Host>


note:
also i tried with /u path outside of /webapps and the same it does not works. /root/apache-tomcat-7.0.61/u/ROOT/index.xml and <Context path="/u" docBase="/root/apache-tomcat-7.0.61/u/ROOT" />


thanks,marius
 
Saloon Keeper
Posts: 25842
184
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because, Tomcat, like all other J2EE/JEE webapps is a web server, not a file server.

You don't just plunk down files somewhere and expect them to work. You have to create a WAR.

A WAR is a JAR (zip) file with a certain required structure, the details of which I won't address here, since they're introduced early on in any book on Enterprise Java webapps. Tomcat will accept WARs in either standard or unzipped ("exploded") forms, but the structure is the same, regardless.

The process of installing a WAR (and hence, a webapp) into Tomcat is known as "deploying", and it can be as simple as dropping a copy of the WAR file into the TOMCAT_HOME/webapps directory or as complex as constructing a sophisticated Tomcat Context file that points to a WAR in some arbitrary filesystem location. These methods, and quite a few more are described in detail in the documentation on the Tomcat website.

The documents also very strongly advice you not to put Context elements in the Tomcat server.xml file. That's an ancient and obsolete practice and the only reason it still works is for special support that not even I have had to resort to (so far!)

Even after properly constructing a WAR and deploying it, to make a given resource render as the default application webpage requires that you define which resource(s) shall do so. That's defined in the webapp's WEB-INF/web.xml file. There are certain restrictions on what will and won't work as a default resource, however.

 
marius tanislav
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks and there is no solved button.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic