• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

context.xml

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i'am new to Servlets.

1) What is the actual use of the "context.xml" file under "Meta-Inf" folder?.

2) what is the difference of setting the context under the "Meta-Inf" and in the "server.xml" which is under the conf folder of Tomcat.

3) If we are going to declare context in either of the two places is it is important to do the same in the other place too?


a detailed explanation would help me a lot.

Thanks in advance
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since these questions are all Tomcat-specific, I've moved this to the Tomcat forum.
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 - The context.xml file is used to describe and setup a context.

2 - The use of a context.xml is new to Tomcat 5.x. In previous versions, the context was added to server.xml and required Tomcat to be restarted to take effect. Now, with the context.xml, we can deploy, redeploy and undeploy contexts without restarting Tomcat.

3 - Only add a context to one place, which place depends on the version of Tomcat you're using.
 
vijaya vinayagam
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Ray Stojonic
thanks for the reply.
When i place the complete project folder directly inside my C:\ and set the context under the "server.xml" and when i start the tomcat i can see my project started by tomcat.

but instead of setting the context in the "server.xml" if i set that in "META-INF/context.xml" and when i start the tomcat i can't see my project running.

i think i'am missing some setting here.

let me know aht should i do.
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I should have mentioned this before...

For the context.xml to be properly deployed from META-INF to the Tomcat conf directory, (which also includes renaming the context.xml to <Your Context Name>.xml) the context must be deployed through Tomcat manager, as a .war file (Web Application Archive)

If you want to deploy it yourself by copying the files to the webapps directory, you'll need to do it this way:

- stop Tomcat
- copy your context to CATALINA_HOME/webapps
- copy your context.xml to CATALINA_HOME/conf/Localhost(?)
- I'm not at my development computer at the moment, I forget the full path to the directory, just go to conf and drill down until you see .xml files
- rename your context.xml to <Your Context Name>.xml (this must match what's defined in the context.xml)
- restart Tomcat

Once you've deployed it the first time, you won't need to copy the context.xml every time, only when you've made changes to it.

If you're interested in using a war to deploy, simply zip your context directory, rename it to <Your Context Name>.war then use Tomcat manager to deploy it.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic