Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is a context xml file or server.xml edit required if servlet application is in webapps

 
Ben Charles
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've recently purchased and going through the Servlet and JSP book written by Budi Kurniawan. I just come to the part in chapter one where I deploy and invoke a servlet. I'm using the example app01a directory and I placed it under Tomcat's webapps directory. I also created an app01a.xml file under localhost. I was able to successfully invoke the servlet once I started Tomcat.

My question is, if an app is located under the webapps directory, do you need to create the xml context file? I removed it from localhost and restarted Apache and everything still worked fine.

What is the best practice? Thanks
 
Dhaval J. Patel
Ranch Hand
Posts: 90
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You dont need to create a context decriptor yourself unless you want to define specific resources related to your web-application or change the default context path etc. As you are in your initial learning phase, I would suggest not to get in the details of that right now, as it would get you confused, and instead focus on getting important base concepts first.

Do not worry about context descriptors as on startup, Tomcat will create one for every web-application present in the web-apps directory if a context descriptor does not exist already.

This is a small piece of information taken from the tomcat docs, which will give you some idea on what happens on startup.

The following deployment sequence will occur on Tomcat startup in that case:

1) Any Context Descriptors will be deployed first.
2) Exploded web applications not referenced by any Context Descriptor will then be deployed. If they have an associated .WAR file in the appBase and it is newer than the exploded web application, the exploded directory will be removed and the webapp will be redeployed from the .WAR
3) .WAR files will be deployed

Note again that for each deployed web application, a Context Descriptor will be created unless one exists already.




 
Ben Charles
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dhaval
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic