How to Set Default Context Path in Apache Tomcat (Windows)
A context path in Apache Tomcat refers to the name of the website as presented by the browser. For example, imagine I tell you to enter "localhost:8080/DemoWebsite/DateJSP.jsp" in your browser. The context path is "DemoWebsite". The term "context" in Tomcat is in fact synonymous with "website". The default context path can be specified if we provide a context file to Tomcat that is given the same name as the website. In this topic, you will learn how to accomplish this important task.
How to Set Default Context Path in Apache Tomcat(Windows)
Written by Stephen Withrow
To learn how to set the default context path in Apache Tomcat in a Windows environment, follow these 9 steps:
- Create a folder named
DemoWebsiteunder the C drive (or another drive letter).
- You will need to store
DateJSP.jspin this folder.
In your text editor, you will develop a context file. Context files are composed of XML statements. Type the following statement in a new file:
The context path will be determined by the name of the file, not the
<Context path="/Placeholder" docBase="c:/DemoWebsite" />
pathattribute value. The
pathattribute is only used by Tomcat if a context is placed in
- Save your file as
- Copy the XML file to
- Start the Tomcat server.
- Start your browser if it is not already running.
- In the address area of the browser, type
http://localhost:8080/DemoWebsite/DateJSP.jspand submit that address to the browser.
- The output of your JSP page will be displayed: