diff --git a/grails-doc/src/en/ref/Servlet API/servletContext.adoc b/grails-doc/src/en/ref/Servlet API/servletContext.adoc
index 5c9228b5245..6da10ed8af8 100644
--- a/grails-doc/src/en/ref/Servlet API/servletContext.adoc
+++ b/grails-doc/src/en/ref/Servlet API/servletContext.adoc
@@ -25,7 +25,7 @@ under the License.
=== Purpose
-The servletContext object is an instance of the Servlet API's {jakartaee}jakarta/servlet/ServletContext.html[ServletContext] class.
+The `servletContext` object is an instance of the Servlet API's {jakartaee}jakarta/servlet/ServletContext.html[ServletContext] class.
=== Examples
diff --git a/grails-doc/src/en/ref/Tag Libraries/actionName.adoc b/grails-doc/src/en/ref/Tag Libraries/actionName.adoc
index d83e464258d..456d18fc8a1 100644
--- a/grails-doc/src/en/ref/Tag Libraries/actionName.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/actionName.adoc
@@ -33,15 +33,20 @@ Returns the name of the currently executing action
[source,groovy]
----
-class BookController {
- def list() {
- log.info "Executing action $actionName"
+class ExamplesTagLib {
- render(view: actionName)
+ def showActionName = { attrs, body ->
+ out << "Executing action: ${actionName}"
}
+
}
----
+[source,xml]
+----
+
+----
+
=== Description
diff --git a/grails-doc/src/en/ref/Tag Libraries/controllerName.adoc b/grails-doc/src/en/ref/Tag Libraries/controllerName.adoc
index 4298f9c7ce5..b77db2c19b1 100644
--- a/grails-doc/src/en/ref/Tag Libraries/controllerName.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/controllerName.adoc
@@ -33,16 +33,20 @@ Returns the name of the currently executing controller
[source,groovy]
----
-class BookController {
+class ExamplesTagLib {
- def list() {
- log.info "Executing within controller $controllerName"
-
- render(view: actionName)
+ def showControllerName = { attrs, body ->
+ out << "Executing controller: ${controllerName}"
}
+
}
----
+[source,xml]
+----
+
+----
+
=== Description
diff --git a/grails-doc/src/en/ref/Tag Libraries/flash.adoc b/grails-doc/src/en/ref/Tag Libraries/flash.adoc
index ab7e12494fe..ec6a720213a 100644
--- a/grails-doc/src/en/ref/Tag Libraries/flash.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/flash.adoc
@@ -33,17 +33,20 @@ A temporary storage map that stores objects within the session for the next requ
[source,groovy]
----
-class BookController {
+class ExamplesTagLib {
- def index() {
+ def message = {
flash.message = "Welcome!"
- redirect(action: 'home')
+ out << "Flash: ${flash}"
}
- def home() {}
}
----
+[source,xml]
+----
+
+----
=== Description
diff --git a/grails-doc/src/en/ref/Tag Libraries/pageScope.adoc b/grails-doc/src/en/ref/Tag Libraries/pageScope.adoc
index 7bd5f7a6eab..c5d3bd4047b 100644
--- a/grails-doc/src/en/ref/Tag Libraries/pageScope.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/pageScope.adoc
@@ -33,7 +33,7 @@ A reference to the binding of the GSP that the tag library is being executed wit
[source,groovy]
----
-class BookTagLib {
+class ExamplesTagLib {
def parent = { attrs, body ->
pageScope.parent = "John"
@@ -43,13 +43,14 @@ class BookTagLib {
def child = { attrs, body ->
out << "My parent is ${pageScope.parent}"
}
+
}
----
[source,xml]
----
- // Outputs "My parent is John"
+
----
diff --git a/grails-doc/src/en/ref/Tag Libraries/params.adoc b/grails-doc/src/en/ref/Tag Libraries/params.adoc
index 202bc3d5e54..75109b21ee0 100644
--- a/grails-doc/src/en/ref/Tag Libraries/params.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/params.adoc
@@ -34,20 +34,18 @@ A mutable multi-dimensional map (hash) of request (CGI) parameters.
To obtain a request parameter called `id`:
[source,groovy]
----
-class BookController {
- def show() {
- def book = Book.get(params.id)
+class ExamplesTagLib {
+
+ def showParameter = {
+ out << "Parameter id has the value ${params['id']}"
}
+
}
----
-To perform data binding (see link:{guidePath}theWebLayer.html#dataBinding[data binding] in the user guide):
-
-[source,groovy]
+[source,xml]
----
-def save() {
- def book = new Book(params) // bind request parameters onto properties of book
-}
+
----
@@ -59,16 +57,8 @@ The standard Servlet API provides access to parameters with the `HttpServletRequ
The `params` object can be indexed into using the array index operator or de-reference operator, so given the URL `/hello?foo=bar` you can access `foo` with
----
-println params.foo
+params['id']
----
The params object can also be used to bind request parameters onto the properties of a domain class using either the constructor or the link:{domainClassesRefFromRef}properties.html[properties] property:
-[source,groovy]
-----
-def book = new Book(params)
-book = Book.get(1)
-book.properties = params
-----
-
-For further reading see link:{guidePath}theWebLayer.html#dataBinding[data binding] in the user guide.
diff --git a/grails-doc/src/en/ref/Tag Libraries/request.adoc b/grails-doc/src/en/ref/Tag Libraries/request.adoc
index 31b689cb7a4..cd7f97066c6 100644
--- a/grails-doc/src/en/ref/Tag Libraries/request.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/request.adoc
@@ -25,7 +25,7 @@ under the License.
=== Purpose
-The link:{servletApiRefFromRef}request.html[request] object is an instance of the Servlet API's {javaee}javax/servlet/http/HttpServletRequest.html[HttpServletRequest] class
+The link:{servletApiRefFromRef}request.html[request] object is an instance of the Servlet API's {jakartaee}jakarta/servlet/http/HttpServletRequest.html[HttpServletRequest] class
=== Examples
@@ -33,19 +33,23 @@ The link:{servletApiRefFromRef}request.html[request] object is an instance of th
[source,groovy]
----
-class BookController {
- def list() {
- log.info "User agent: ${request.getHeader("User-Agent")}"
+class ExamplesTagLib {
- render(view: actionName)
+ def showRequest = { attrs, body ->
+ out << "Request ${request.getHeader('User-Agent')}"
}
+
}
----
+[source,xml]
+----
+
+----
=== Description
-The {javaee}javax/servlet/http/HttpServletRequest.html[HttpServletRequest] class is useful for, amongst other things, obtaining request headers, storing request scoped attributes and establishing information about the client. Refer to the Servlet API's javadocs for further information.
+The {jakartaee}jakarta/servlet/http/HttpServletRequest.html[HttpServletRequest] class is useful for, amongst other things, obtaining request headers, storing request scoped attributes and establishing information about the client. Refer to the Servlet API's javadocs for further information.
NOTE: The additional methods added to the link:{servletApiRefFromRef}request.html[request] object are documented in the Grails Servlet API reference guide
diff --git a/grails-doc/src/en/ref/Tag Libraries/response.adoc b/grails-doc/src/en/ref/Tag Libraries/response.adoc
index 852d5b359c1..9464ca7308e 100644
--- a/grails-doc/src/en/ref/Tag Libraries/response.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/response.adoc
@@ -25,7 +25,7 @@ under the License.
=== Purpose
-The {grailsdocs}ref/Servlet%20API/response.html[response] object is an instance of the Servlet API's {javaee}javax/servlet/http/HttpServletResponse.html[HttpServletResponse] class
+The link:{servletApiRefFromRef}response.html[response] object is an instance of the Servlet API's {jakartaee}jakarta/servlet/http/HttpServletResponse.html[HttpServletResponse] class
=== Examples
@@ -33,11 +33,12 @@ The {grailsdocs}ref/Servlet%20API/response.html[response] object is an instance
[source,groovy]
----
-class BookController {
- def downloadFile() {
- byte[] bytes = // read bytes
- response.outputStream << bytes
+class ExamplesTagLib {
+
+ def setHeader = {
+ response.setHeader('Content-Type', 'text/html; charset=utf-8')
}
+
}
----
@@ -45,6 +46,6 @@ class BookController {
=== Description
-The Servlet API's `HttpServletResponse` class can be used within Grails to perform all typical activities such as writing out binary data, writing directly to the response and sending error response codes to name but a few. Refer to the documentation on the {javaee}javax/servlet/http/HttpServletResponse.html[HttpServletResponse] class in the Servlet API for more information.
+The Servlet API's `HttpServletResponse` class can be used within Grails to perform all typical activities such as writing out binary data, writing directly to the response and sending error response codes to name but a few. Refer to the documentation on the {jakartaee}jakarta/servlet/http/HttpServletResponse.html[HttpServletResponse] class in the Servlet API for more information.
NOTE: The additional methods added to the link:{servletApiRefFromRef}response.html[response] object are documented in the Grails Servlet API reference guide
diff --git a/grails-doc/src/en/ref/Tag Libraries/servletContext.adoc b/grails-doc/src/en/ref/Tag Libraries/servletContext.adoc
index ea902e3a4db..c468a178af8 100644
--- a/grails-doc/src/en/ref/Tag Libraries/servletContext.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/servletContext.adoc
@@ -25,7 +25,7 @@ under the License.
=== Purpose
-The link:{servletApiRefFromRef}servletContext.html[servletContext] object is an instance of the Servlet API's {javaee}javax/servlet/ServletContext.html[ServletContext] class.
+The link:{servletApiRefFromRef}servletContext.html[servletContext] object is an instance of the Servlet API's {jakartaee}jakarta/servlet/ServletContext.html[ServletContext] class.
=== Examples
@@ -33,18 +33,12 @@ The link:{servletApiRefFromRef}servletContext.html[servletContext] object is an
[source,groovy]
----
-class BookController {
- def doSomething() {
- def input
- try {
- input = servletContext.getResourceAsStream("/WEB-INF/myscript.groovy")
- def result = new GroovyShell().evaluate(input.text)
- render result
- }
- finally {
- input.close()
- }
+class ExamplesTagLib {
+
+ def doSomething = {
+ out << "Servlet major version: ${servletContext.majorVersion}"
}
+
}
----
@@ -52,6 +46,6 @@ class BookController {
=== Description
-The Servlet API's {javaee}javax/servlet/ServletContext.html[ServletContext] is useful for, amongst other things, storing global application attributes, reading local server resources and establishing information about the servlet container.
+The Servlet API's {jakartaee}jakarta/servlet/ServletContext.html[ServletContext] is useful for, amongst other things, storing global application attributes, reading local server resources and establishing information about the servlet container.
NOTE: Grails adds additional methods to the standard Servlet API's link:{servletApiRefFromRef}servletContext.html[servletContext] object. See link for details.
diff --git a/grails-doc/src/en/ref/Tag Libraries/session.adoc b/grails-doc/src/en/ref/Tag Libraries/session.adoc
index 68ffee316b2..fd20cb2037a 100644
--- a/grails-doc/src/en/ref/Tag Libraries/session.adoc
+++ b/grails-doc/src/en/ref/Tag Libraries/session.adoc
@@ -25,7 +25,7 @@ under the License.
=== Purpose
-The {grailsdocs}ref/Servlet%20API/session.html[session] object is an instance of the Servlet API's {javaee}javax/servlet/http/HttpSession.html[HttpSession] class
+The link:{servletApiRefFromRef}session.html[session] object is an instance of the Servlet API's {jakartaee}jakarta/servlet/http/HttpSession.html[HttpSession] class
=== Examples
@@ -33,22 +33,31 @@ The {grailsdocs}ref/Servlet%20API/session.html[session] object is an instance of
[source,groovy]
----
-class UserController {
+class ExampleTagLib {
- def logout() {
- log.info "User agent: " + request.getHeader("User-Agent")
- session.invalidate()
- redirect(action: "login")
- }
+ def oncePerSession = { Map attrs, body ->
+ def key = (attrs.key ?: 'default').toString()
+ def sessionKey = "taglib.oncePerSession.${key}"
- def login() {}
+ if (!session.getAttribute(sessionKey)) {
+ session.setAttribute(sessionKey, true)
+ out << body()
+ }
+ }
}
----
+[source,xml]
+----
+
+ Free shipping this week!
+
+----
+
=== Description
-The {javaee}javax/servlet/http/HttpSession.html[HttpSession] class is useful for associated session data with a client.
+The {jakartaee}jakarta/servlet/http/HttpSession.html[HttpSession] class is useful for associated session data with a client.
NOTE: The additional methods added to the link:{servletApiRefFromRef}session.html[session] object are documented in the Grails Servlet API reference guide