title: Get Path Parameters within Action Composition - Play Framework
body: <p>I have a route </p>
  
  <p><code>GET      /students/:id/edit controllers.StudentsController.edit(id: Long)</code> </p>
  
  <p>and I want to do some validations before hitting the controllers itself</p>
  
  <pre><code>@With(ValidStudentIdAction.class)
  public Result edit(long id) {
  // ... edit stuff
  }
  
  public class ValidStudentIdAction extends play.mvc.Action.Simple {
      public CompletionStage&lt;Result&gt; call(Http.Context ctx) {
        long id receives the :id from request
  
        // now I know the id, I can verify if exist some Student with
        // this id, else return an error
        // ...
  
        return delegate.call(ctx);
      }
  }
  </code></pre>
  
  <p>The problem is, how can I get the <code>:id</code> from the request ? calling <code>ctx.request()</code> returns  me <code>GET /students/{the id I want}/edit</code>, but the <a href="https://www.playframework.com/documentation/2.5.x/api/java/index.html" rel="nofollow">docs</a> don't specify a way to get this <code>:id</code>. Is possible to get the <code>:id</code> in a portable way without doing some non portable regex ?</p>
  
  <p><b>note:</b> I'm not dealing with query parameters, the URL's are like <code>controller/id/action</code></p>