title: How to use Spring AOP to run code before every call of service method in Servlet
body: <p>I have some common code must be injected into <code>service</code> method of any servlet . </p>
  
  <p>Thus, i build a mother servlet <code>SuperController</code> :</p>
  
  <pre><code>public class SuperController extends HttpServlet{
       private HttpServletRequest lastRequest ; 
       //........
       public void service(HttpServletRequest req,HttpServletResponse res){
            setLastRequest(req); // example of common code
       }
  }
  </code></pre>
  
  <p>Then, all other servlets extends from this servlet . </p>
  
  <pre><code>public GalleryServlet extends SuperController{
  
        public void service(HttpServletRequest req,HttpServletResponse res){
             //instead of running here the common code , use AOP. 
             // Then , the other code
        }
  
  }
  </code></pre>
  
  <p>I want to execute the common code ( i.e: <code>setLastRequest(req)</code>) using AOP , since <code>super.service(req,res)</code> raised <code>ERROR 405</code> . </p>
  
  <h1>com.ControllerAspect.java</h1>
  
  <pre><code>@Before("* com.SuperController+.service(..)")
  public void doStuffBeforeService(JoinPoint joinPoint) {
      // do stuff here
  }
  </code></pre>
  
  <h2>How to Use Spring AOP :</h2>
  
  <ul>
  <li><p>Does this pointcut <code>* com.SuperController+.service(..)</code> includes <code>service</code> methods in all classes inherits from <code>com.SuperController</code> . </p></li>
  <li><p>How to access to arguments (req &amp; res ) of service method inside  <code>doStuffBeforeService</code> ? </p></li>
  </ul>