PDF version
Expressions
Introduction
Many Gomba servlet init-params accept expressions that are dynamically evaluated for each HTTP request. Expressions may be used to parameterize SQL statements, set HTTP response header values, etc.
Parameters
Expressions use the familiar ${...} syntax from Ant and JSP 2.0 to identify dynamic values. Each ${} fragment is called a parameter. Parameters have the following syntax:
${domain.paramName [JavaType] [defaultValue]}
JavaType and defaultValue are optional.
Double quotes (") may be used to enclose strings containing spaces. Backslashes (\) may be used to escape any character. If the default value is the literal null, then parameter may evaluate to null without causing an exception.
Domains
Parameters are organized into domains that contain a set of name/value pairs. Available domains are:
| name | description | example |
|---|---|---|
| path | This domain contains properties extracted from the servlet request extra path. Each path element is named with an integer starting from 0. | ${path.0} |
| param | This domain contains properties extracted from the servlet request parameters. | ${param.myParam} |
| paramValues | This domain contains properties extracted from the servlet request parameters. All values for that parameter can be accessed. | ${paramValues.myParam.0} |
| header | This domain contains properties extracted from the servlet request HTTP headers. | ${header.myHeader} |
| requestScope | This domain contains properties extracted from the servlet request attributes. Request attributes can be set by the JSP that generates the dynamic SQL. | ${requestScope.myAttribute} |
| column | This domain contains properties extracted from the first row of the ResultSet. Properties have the name of the corresponding columns. | ${column.myColumn} |
| blob | This domain contains properties extracted from the first row of the ResultSet for column of type BLOB. Properties have the name of the corresponding columns. This is useful only for the LOBUpdateServlet. | ${blob.myColumn} |
| clob | This domain contains properties extracted from the first row of the ResultSet for column of type CLOB. Properties have the name of the corresponding columns. This is useful only for the LOBUpdateServlet. | ${clob.myColumn} |
Java types
JavaType must be a valid Java class name (e.g. java.lang.Integer). If JavaType is specified the parameter value is converted using ConvertUtils from the Commons BeanUtils package. Conversions are performed only from Strings to the following types:
- java.lang.Integer and the int primitive.
- java.lang.Long and the long primitive.
- java.lang.Double and the double primitive.
- java.lang.Float and the float primitive.
- java.lang.Boolean and the boolean primitive.
- java.lang.Byte and the byte primitive.
- java.lang.Character and the character primitive.
- java.lang.BigDecimal
- java.lang.BigInteger
-
java.util.Date. Only the following ISO8601 formats
are supported:
- 1997-07-16T19:20:30.45-02:00
- 1997-07-16T19:20:30+01:00
- 1997-07-16T19:20:30
- 1997-07-16T19:20
- 1997-07-16
- 1997-07
- 1997
Examples
- ${path.0 java.lang.Integer}
- Gets the value of the first extra path element and converts it to an integer. Suppose your Gomba servlet has the following servlet-mapping /myservlet/* and is available at http://localhost:8080/myservice/. For an URL like http://localhost:8080/myservice/myservlet/123 ${path.0 java.lang.Integer} evaluates to 123.
- ${param.myParam java.util.Date}
- Gets the value of the myParam request parameter and converts it to date. http://localhost:8080/myservice/myservlet?myParam=1976-05-24