Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6046231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:12:54+00:00 2026-05-23T07:12:54+00:00

In Grails the flash storage object is used to hold onto cross request data

  • 0

In Grails the flash storage object is used to hold onto cross request data like messages.

I know that it can be accessed from most Views and Controllers, but I’m not sure if it’s available universally across Grails, or if it can only be accessed from certain conventional objects.

Can the flash object be accessed from Services, for instance?

Or even anywhere during a live web request?

What are it’s precise limitations in terms of access?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:12:54+00:00Added an answer on May 23, 2026 at 7:12 am

    You can gain access to the flash wherever, and more importantly, whenever you have access to a web request. In general, you can get the flash from the GrailsWebRequest object.

    import org.codehaus.groovy.grails.web.util.WebUtils
    
    def grailsWebRequest = WebUtils.retrieveGrailsWebRequest()
    // request is the HttpServletRequest
    def flash = grailsWebRequest.attributes.getFlashScope(request)
    

    If you invoke retrieveGrailsWebRequest() outside the context of a web request, you’ll get an IllegalStateException. The GrailsWebRequest is bound to the current thread by a filter, GrailsWebRequestFilter, which is executed early in the service request. So basically, as long as you’re in the context of a request and “inside” this filter execution, you should be able to access the flash.

    Beyond that, take a look at the source for org.codehaus.groovy.grails.web.servlet.DefaultGrailsApplicationAttributes. The flash storage is saved in the session, so theoretically you should be able to use it once you gain access to the session. Be careful though, since it’s shared among the different request for the session. The mentioned filter is responsible for advancing the state of the flash throughout requests, essentially popping a ConcurrentHashMap from a 2-element queue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grails project with a class that I can delete no problem
Grails tends to write out the URL for everything that uses its tags as
The Grails framework has a lot of constructs/features that allows for adhering to the
In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params)
I'm using Grails 1.1 beta2. I need to import a large amount of data
Basically I have 2 questions regarding grails filters. According to grails documentation you can
i have some knowledge of css,jQuery,Grails,django,servlets and jsp still i can't see me designing
Using Grails 2.0.0 I am created service, that creates instances of Player class and
I have the included grails script that I found in some random place on
Grails provides filters that run before your controllers. They're defined in classes that look

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.