I am using Tomcat 6.0.18, JDK 1.5 on CentOS 5. From within a JSP page, applicaton.getRealPath() is returning results that I wasn't expecting.
Say, my application root directory in CentOS is "app-root". From within app-root/dir-a/test.jsp, I am using application.getRealPath(). Here are the results and what I expected: ("/"): app-root/dir-a/ --- expected: app-root ("/test"): app-root/dir-a/test --- expected: app-root/test ("test"): app-root/dir-a/test --- expected: app-root/dir-a/test According to the JSP Spec 2.0: *** "application" javax.servlet.ServletContext The servlet context obtained from the servlet configuration object (as in the call getServlet-Config().getContext() ), application scope *** Is Tomcat treating "dir-a" as an application, giving it its own ServletContext? I do see the following in the auto-deployment section in Tomcat doc: *** Any subdirectory within the application base directory will receive an automatically generated Context element, even if this directory is not mentioned in the conf/server.xml file. This generated Context entry will be configured according to the properties set in any DefaultContext element nested in this Host element. The context path for this deployed Context will be a slash character ("/") followed by the directory name, unless the directory name is ROOT, in which case the context path will be an empty string (""). http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Applica tion%20Deployment *** However, turning auto-deploy on or off (in server.xml) does not make any difference. "dir-a" is a simple directory that is not mentioned in any context related conf files or contains any context XMLs. Any insight will be appreciated. Qiao