Request, response and session objects are implicitly available in controllers, views and tag libraries and hence we can easily set or get data from these objects but in services these objects are not implicitly available.

If you want to set or get data from these objects in services then first you have to get these objects. Following is the simple code to get these objects in service:

import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
import org.codehaus.groovy.grails.web.util.WebUtils


GrailsWebRequest webUtils = WebUtils.retrieveGrailsWebRequest()
def request = webUtils.getCurrentRequest()
def response = webUtils.getCurrentResponse()
def service = webUtils.getSession()