May 15th, 2007, 07:11 PM
retrieving current Http Request from a Spring Bean
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.
May 16th, 2007, 03:21 AM
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.
May 16th, 2007, 06:37 AM
What is it that you want to do with the HttpSession?