The Active Web servlet uses files for many different activities. As the servlet is platform independent we need a way of identifying files that allows scripts to be run on different platforms without having to make changes to the scripts.

For all script file references the servlet uses the following rules:

  1. File are referenced by names. The name can include directories and the '/' separator (the one used for URL addresses) must be used between directories. A directory of '..' (two full stops) means move up one directory.

  2. If the name does not start with a separator ('/') then it is relative to the directory that the holds the executing script.

  3. If the name starts with a single separator ('/') then it is relative to the root of the web application.

  4. If the name starts with a double separator ('//') then it is relative to the operating system root. This is referred to as an absolute reference.

  5. The '..' directory reference does not let you move up through the web application root directory.

In some situations the servlet does not allow absolute references (references outside the root of the web application).

Below are some examples:

Executing script = C:\tomcat\webapps\concerto\testing\home.html

'libs.js' refers to file C:\tomcat\webapps\concerto\testing \libs.js

'../syslib/libs.js' refers to file C:\tomcat\webapps\concerto\testing\syslib\libs.js

'/syslib/libs.js' refers to file C:\tomcat\webapps\concerto\testing\syslib\libs.js

'//C:\tomcat\webapps\concerto\testing /syslib/libs.js' refers to file C:\tomcat\webapps\concerto\testing\syslib\libs.js

Comment on this topic

Topic ID: 150092