Sun Java System Web Server 7.0 Update 6 Administrator's Configuration File Reference

String Interpolation

Strings that contain references to variables or expressions are called interpolated strings. When you use interpolated strings, the embedded expressions and variables are evaluated and the result is inserted into the string. The act of inserting data into a string is called string interpolation.

Use interpolated strings in expressions, log formats, and obj.conf parameters. In expressions, only string literals bracketed by double quotes are interpolated. For more information, see Expression Literals.

Using Variables in Interpolated Strings

To include the value of a variable in a string, prefix the name of the variable with the dollar-sign ($). For example, the following format element in server.xml logs the client IP address, requested URI, and corresponding file system path for each HTTP request:

  <format>$ip "$uri" $path</format>

In this example, $ip, $uri, and $path are predefined variables. For more information, see Variables.

For more information on access logs and log format, see Appendix C, Using the Custom Log File Format. For more information on the access-log element in server.xml, see access-log.

If the name of the variable is ambiguous, add curly braces, {}, to the name. For example, the following string contains a reference to the predefined $path variable:


Without the curly braces, the string instead contains a reference to a hypothetical variable named pathhtml.

Using Expressions in Interpolated Strings

To include the result of an expression in a string, prefix the expression with $(and follow it with ). For example, the following two strings are identical after interpolation:

"$(2 + 2)"


When an interpolated string is used as an obj.conf parameter, the string is interpolated each time the corresponding instruction is executed. For example, the following lines could be used in obj.conf to redirect clients based on the requested URI and the contents of the file redirect.conf:

<Object ppath="/redirect/*">
NameTrans fn="redirect" url="$(lookup('redirect.conf', $uri, '/'))"

In this example, the expression lookup('redirect.conf', $uri, '/') is evaluated each time the NameTrans directive is invoked, and the result is passed to the redirect SAF in its url parameter. For more information on the redirect SAF, see redirect. For more information on the lookup expression function, see lookup.