8.2.2.1 Variables and Scopes - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.1.4
8.2.2.1 Variables and Scopes
Variables can be defined within a GSP using the set tag:<g:set var="now" value="${new Date()}" />now to the result of a GSP expression (which simply constructs a new java.util.Date instance). You can also use the body of the <g:set> tag to define a variable:<g:set var="myHTML"> Some re-usable code on: ${new Date()} </g:set>
<g:set var="bookService" bean="bookService" />- page- Scoped to the current page (default)
- request- Scoped to the current request
- flash- Placed within flash scope and hence available for the next request
- session- Scoped for the user session
- application- Application-wide scope.
scope attribute:<g:set var="now" value="${new Date()}" scope="request" />