Announcement Announcement Module
No announcement yet.
passing HttpRequest info to aspect. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • passing HttpRequest info to aspect.

    Hi everybody,

    I use spring at business and data layers (JPA + hibernate) but not at web layer (not using Spring MVC). At web layer, Java Page Flow /JPF) is used instead.

    I have an AOP aspect to trace transactions at business and dao layers,
    it is configured to execute when a service or dao method executes.

    But it is required that user info must also be logged. But the problem is business and dao layers doesn't "know" HttpRequest/Session object that holds user information (request.getRemoteUser())

    Do you have any idea to pass this info to business layer ?

  • #2
    One option might be to inject a session- or request-scoped bean containing user information. See here for an example:
    Last edited by Mike Bingham; Oct 2nd, 2007, 07:34 PM.


    • #3

      Thanks for your reply. It's definetely working...

      This is the solution:
      after adding this listener to web.xml :

      it is possible to reach HttpRequest and HttpSession objects.

      I can reach the user by this statement:

      ServletRequestAttributes requestAttributes = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
      String userName = requestAttributes.getRequest().getRemoteUser();
      as always Spring has a solution.