Announcement Announcement Module
Collapse
No announcement yet.
retrieving current Http Request from a Spring Bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • retrieving current Http Request from a Spring Bean

    Hello,

    I would like to retrieve the HTTP request from a Spring Bean if it is running in a WebApplicationContext.

    With ApplicationContextAware I've got an ApplicationContext and after casting a WebApplicationContext and could like that get the ServletContext.

    But I could not find how to retreive the current http request. Is it possible ?

    I know it is a strange need, but if it is possible I'll use it for testing purpose.
    Thanks
    Cyrille

  • #2
    No, not directly. You can use RequestContextListener and RequestContextHolder, retrieve currentRequestAttributes() from the latter where RequestAttributes is a Spring interface. If that's not sufficient you can cast it to ServletRequestAttributes and call getRequest() on it to have access to the HttpServletRequest.

    Jörg

    Comment


    • #3
      What is it that you want to do with the HttpSession?

      Comment

      Working...
      X