Creating a Context
Before writing a servlet, you need a place to put it. Shut down your server, if it is running.
In the file jakarta-tomcat-X.X/conf/server.xml, find the example Context elements.
Add a new context element such as:
<Context path=“/dbc” docBase=“webapps/dbc/”
debug=“0” reloadable=“true”>
</Context>
- The path attribute defines a logical path that appears in the URL.
- The docBase attribute defines the physical directory where HTML and servlets live.
- Be careful to put /s in all the right places!
- The reloadable flag is supposed to allow servlet classes to be reloaded into a running server if they have been modified. We set it true because that is the recommended default during development. Note, however, it does not work very reliably!