File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

context.xml

 
vijaya vinayagam
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since these questions are all Tomcat-specific, I've moved this to the Tomcat forum.
 
Ray Stojonic
Ranch Hand
Posts: 326
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic