EL Variables
Resin

Change Log
Documentation

Orientation
Features
Installation
Configuration
Web Applications
JSP
Servlets and Filters
Databases
Admin (JMX)
Security
XML and XSLT
XTP
Resources (JNDI)
Performance
Protocols
Third-party
Troubleshooting

env
web-app
resin.conf
log
el vars
init
index
Common Tasks
Relax Schema
Config FAQ
Scrapbook
log
Configuration
init

Resin's configuration files support JSP EL expressions in several contexts.

For the full JSP EL syntax, see the JSP 2.0 specification.

  1. Special Variables
  2. jndi:lookup
  3. Servlet/Filter bean-style initialization

Special Variables

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
variableattributemeaning
Var System properties, e.g. ${Var["resin.home"]}
server Server properties
 nameThe server id, as specified in -server id
 rootDirThe server root directory, $SERVER_ROOT
 docDirThe server document directory
host Virtual host properties
 urlThe host's canonical URL
 nameThe host name
 rootDirThe host's root directory
 docDirThe host's document directory
 warDirThe host's war directory
 warExpandDirThe host's war expansion directory
 regexpRegular expression values for host regexp matches
app web-app properties
 urlThe web-app's canonical URL
 nameThe web-app name
 contextPathThe web-app's context path
 docDirThe web-app's document directory
 regexpRegular expression values for web-app url-regexp matches

jndi:lookup

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>

Servlet/Filter bean-style initialization2.1.3

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>


log
Configuration
init
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.