wood burning stoves 2.0*
The moose likes Servlets and the fly likes Is a context xml file or server.xml edit required if servlet application is in webapps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is a context xml file or server.xml edit required if servlet application is in webapps " Watch "Is a context xml file or server.xml edit required if servlet application is in webapps " New topic
Author

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

Ben Charles
Greenhorn

Joined: Feb 29, 2012
Posts: 7
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

Joined: Mar 10, 2011
Posts: 90

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

Joined: Feb 29, 2012
Posts: 7
Thanks Dhaval
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is a context xml file or server.xml edit required if servlet application is in webapps
 
Similar Threads
about context file
Manage DataSource via Spring issue
Tomcat Configuration with more than 2,000 apps
Giving Tomcat Project under Eclipse a needed config .xml file?
Eclipse Integrated with Tomcat for Hot Deployment