1. Add a virtual directory (that is, you can use this element to set web applications that are not in the default webapps folder of Tomcat.Program)
Add <context Path = "/OICQ" docbase = "myweb" DEBUG = "0" reloadable = "true"> to the server. xml file.
</Context>
Myweb indicates its location relative to webapps, which is a physical directory;
/OICQ indicates its relative web URL path, which is a virtual path, for example, http: // localhost/OICQ
Another example:
<Context Path = "/jspandservletcookbook" reloadable = "true" docbase = "G:/resource/Java/jspandservletcookbook" workdir = "G: /resource/Java/jspandservletcookbook/Work "/>
2 enable Servlet
One reason for creating a custom URL for the servlet or JSP page is that you can register to read the initialization parameters from the init (servlet) or jspinit (JSP page) method. However, the initialization parameter can be used only when the servlet or JSP page is accessed using the custom URL mode or registration name. The default URL http: // host/webappprefix/servlet/servletname cannot be used for access. Therefore, you may want to disable the default URL so that no one will call the initialization servlet accidentally. This process is sometimes called the Enable servlet, because most servers have a standard servlet registered with the default servlet URL and activate the actual servlet of the default URL application.
There are two main ways to disable this default URL: