| Resin 3.1
Documentation Examples Changes
Overview Installation Configuration Quercus SOA/IoC JSP Servlets and Filters Admin (JMX) EJB Amber Security Performance Hessian XML and XSLT Third-party Troubleshooting/FAQ
tags Common Tasks Relax Schema howto Config FAQ Scrapbook DB Scrapbook
env tags <resin> <cluster> <server> port tags <host> <web-app> <database> session tags rewrite tags service tags log el variables el control
| |
Each Environment in Resin has an associated set of EL variables and functions, and
Resin's configuration files support EL expressions.
ExamplesServlet/Filter initializationEL expressions can be used to configure servlets and
filters. init-param values can use JSP EL expressions, including the
ability to use system properties. Servlets, filters, and resources can be configured like beans with setter
methods are called directly (See Bean-style
init). One example use use for the bean-style servlet initialization is to avoid
JNDI lookup inside the servlet code. For example, a servlet that that uses a
JDBC DataSource might look like: Servlet using JDBC
package test;
...
public class TestServlet extends HttpServlet {
private DataSource _dataSource;
/**
* Bean setter is called to configure the servlet
* before the init() method.
*/
public void setDataSource(DataSource dataSource)
{
_dataSource = dataSource;
}
...
}
The servlet is configured as follows: Example configuration
<web-app>
<allow-servlet-el/>
<servlet servlet-name='test'
servlet-class='test.TestServlet'>
<init>
<data-source>${'${'}jndi("java:comp/env/jdbc/test")}</data-source>
</init>
</servlet>
...
</web-app>
The <data-source> xml tag corresponds to the
setDataSource method of the bean. More infomation on this
powerful pattern is in the bean configuration
section of the documentation. cluster cluster propertiesvariable | meaning |
---|
id | The cluster id | root | The location of the content | Environment variables
Environment variables inherited by the process from the operting system are
available as variables in el expressions, for example .
fmt.sprintf() Format a string using a sprintf-like format string. fmt.sprintf(format[,arg1, arg2 ... argN])
|
format | the format string (see below) | required | arg1..argN | the values used for the conversions in the format string | n/a |
sprintf accepts a series of arguments, applies to each a format
specifier from `format', and returns the formatted data as a string.
`format' is a string containing two types of objects: ordinary
characters (other than `%'), which are copied unchanged to the output, and
conversion specifications, each of which is introduced by `%'. (To include
`%' in the output, use `%%' in the format string).
A conversion specification has the following form: %[FLAGS][WIDTH][.PREC][TYPE]
|
TYPE is required, the rest are optional. The following TYPE's are supported: %% | a percent sign | %c | a character with the given number | %s | a string, a null string becomes "#null" | %z | a string, a null string becomes the empty string "" | %d | a signed integer, in decimal | %o | an integer, in octal | %u | an integer, in decimal | %x | an integer, in hexadecimal | %X | an integer, in hexadecimal using upper-case letters | %e | a floating-point number, in scientific notation | %E | a floating-point number, like %e with an upper-case "E" | %f | a floating-point number, in fixed decimal notation | %g | a floating-point number, in %e or %f notation | %G | a floating-point number, like %g with an upper-case "E" | %p | a pointer (outputs a value like the default of toString()) |
Intepret the word `integer' to mean the java type long.
Since java does not support unsigned integers, all integers are treated
the same. The following optional FLAGS are supported: 0 | If the TYPE character is an integer leading zeroes are used
to pad the field width instead of spaces (following any
indication of sign or base). | + | Include a `+' with positive numbers. | (a space) | use a space placeholder for the `+' that would result
from a positive number | - | The result of is left justified, and the right is padded with
blanks until the result is `WIDTH' in length. If you do not
use this flag, the result is right justified, and padded on
the left. | # | an alternate display is used, for `x' and `X' a
non-zero result will have an "0x" prefix; for floating
point numbers the result will always contain a decimal point. | j | escape a string suitable for a Java string, or a CSV file.
The following escapes are applied: " becomes \",
newline becomes \n, return becomes \r, \ becomes \\. | v | escape a string suitable for CSV files, the same as `j'
with an additional " placed at the beginning
and ending of the string | m | escape a string suitable for a XML file. The following
escapes are applied: < becomes <,
> becomes > & becomes &
' becomes ', " becomes &034; |
The optional WIDTH argument specifies a minium width for the field.
Spaces are used unless the `0' FLAG was used to indicate 0 padding. The optional PREC argument is introduced with a `.', and gives the
maximum number of characters to print; or the minimum
number of digits to print for integer and hex values; or the maximum
number of significant digits for `g' and `G'; or the number of digits
to print after the decimal point for floating points. fmt.timestamp() Format a timestamp string. fmt.timestamp(format[,date])
msg="The current date and time is ${'${'}fmt.timestamp('%Y/%m/%d %H:%M:%S.%s')}"
msg="time=${'${'}fmt.timestamp('[%Y/%m/%d %H:%M:%S.%s]')}"
format contains regular characters, which are just copied to
the output string, and percent codes which are substituted with time and date
values.
Code | Meaning |
---|
%a | day of week (short) | %A | day of week (verbose) | %b | day of month (short) | %B | day of month (verbose) | %c | Java locale date | %d | day of month (two-digit) | %H | 24-hour (two-digit) | %I | 12-hour (two-digit) | %j | day of year (three-digit) | %m | month (two-digit) | %M | minutes | %p | am/pm | %S | seconds | %s | milliseconds | %W | week in year (three-digit) | %w | day of week (one-digit) | %y | year (two-digit) | %Y | year (four-digit) | %Z | time zone (name) | %z | time zone (+/-0800) |
host host propertiesvariable | meaning |
---|
name | The name of the host | regexp | Regular expression values for host regexp matches | root | The root directory of the host | url | The canonical url of the host | Example
<host regexp="www.([^.]+).com">
<root-directory>/opt/www/${host.regexp[1]}</root-directory>
<context-param server-id="${server.name}"/>
<web-app id="/">
<document-directory>webapps/ROOT</document-directory>
</web-app>
</host>
java java propertiesvariable | meaning |
---|
version | The JDK version | jndi() The configuration EL supports the static function jndi:lookup.
jndi:lookup can be used to lookup a JNDI value for the configuration. configuring JNDI
<servlet servlet-name='foo'
servlet-class='qa.FooServlet'>
<init>
<data-source>${'${'}jndi:lookup("java:comp/env/jdbc/test")}</data-source>
</init>
</servlet>
resin resin propertiesvariable | meaning |
---|
address | The local IP address | conf | Path to the configuration file | home | The the location of the Resin executables | hostname | The local hostname as returned by InetAddress | root | The location of the content, specified at startup with --resin-root | serverId | The identity of the active <server>, specified at startup with --server | version | The resin version, e.g. 3.1.0 | server
Values related to the active <server>.
server propertiesvariable | meaning |
---|
address | the bind address of the cluster and load balancing port | id | The identity of the active <server>, specified at startup with --server | port | the cluster and load balancing port | httpAddress | the bind address of the http listener, INADDR_ANY for all addresses | httpPort | the port number of the http listener | httpsAddress | the bind address of the ssl http listener, INADDR_ANY for all addresses | httpsPort | the port number of the ssl http listener | System properties
System properties are available as variables in el expressions.
Many system property names are not valid el
identifiers; in that case the Var variable is used, for example
.
A full list of standard java system properties is provided in the javadoc for
java.lang.System.
Standard system propertiesvariable | meaning |
---|
java.io.tmpdir | Default temp file path | os.name | Operating system name | os.arch | Operating system architecture | os.version | Operating system version | user.name | User's account name | user.home | User's home directory | user.dir | User's current working directory | webApp webApp propertiesvariable | meaning |
---|
name | The name of the web-app | contextPath | The context path of the web-app | regexp | Regular expression values for web-app regexp matches | root | The root directory of the web-app | url | The canonical url of the web app |
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved. Resin ® is a registered trademark, and Quercustm, Ambertm, and Hessiantm are trademarks of Caucho Technology. |
|