|
|  |
Resin's configuration files support JSP EL expressions in
several contexts.
For the full JSP EL syntax, see the JSP 2.0 specification.
host regexp
<host regexp="www.([^.]+).com">
<root-directory>/opt/www/${host.regexp[1]}</root-directory>
<document-directory>${host.rootDir}/doc</document-directory>
<context-param server-id="${server.name}"/>
</host>
|
Special variables
| variable | attribute | meaning
|
| Var | | System properties, e.g. ${Var["resin.home"]}
|
| server | | Server properties
|
| | name | The server id, as specified in -server id
|
| | rootDir | The server root directory, $SERVER_ROOT
|
| | docDir | The server document directory
|
| host | | Virtual host properties
|
| | url | The host's canonical URL
|
| | name | The host name
|
| | rootDir | The host's root directory
|
| | docDir | The host's document directory
|
| | warDir | The host's war directory
|
| | warExpandDir | The host's war expansion directory
|
| | regexp | Regular expression values for host regexp matches
|
| app | | web-app properties
|
| | url | The web-app's canonical URL
|
| | name | The web-app name
|
| | contextPath | The web-app's context path
|
| | docDir | The web-app's document directory
|
| | regexp | Regular expression values for web-app url-regexp matches
|
The configuration EL supports a single 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>
|
EL 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 and filters can be
configured like beans, i.e. having setter methods called directly.
One main 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 could be configured as follows:
Example configuration
<web-app>
<allow-servlet-el/>
<servlet servlet-name='test'
servlet-class='test.TestServlet'>
<init>
<data-source>${jndi:lookup("java:comp/env/jdbc/test")}</data-source>
</init>
</servlet>
...
</web-app>
|
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. |  |
|