Results 1 to 3 of 3

Thread: retrieving current Http Request from a Spring Bean

  1. #1
    Join Date
    Jul 2006
    Posts
    22

    Default 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. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    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

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •