title: How to obtain HTTPServletRequest in AspectJ
body: <p>I need to add some audit logs to some business methods that are not in the web tier. One of the requirements are to store in this audit logs the user that executed the business method and the IP of the remote terminal. I decided to use AspectJ to Audit all this methods to avoid contaminating them with no bussiness code. (Note: I'm not using Spring, this is an old Struts 1 webapp)</p>
  
  <pre><code>public void myMethod(Object param, HttpRequest request**){
       //Bussiness code that never use request param
  }
  
  @After("bla bla matches myMethod")
  public void myAdvice(JoinPoint jp){
      Object request = (HttpServletRequest)jp.getArgs()[1];
      //bla bla using the request to get user and IP
  }
  </code></pre>
  
  <p>So my question is, does anyone have any suggestion to obtain in a better or elegant way the Servlet Request in the Advice? In fact, myMethod does not contain Audit code (that is really good) but now have a second parammeter that is not used directly by the method and can become confusing to other developers. Please do not recomend me to advice the Servlet instead the business method.</p>