title: In Jersey, can I combine QueryParams and FormParams into one value for a method?
body: <p>I've got a function like:</p>
  
  <pre><code>@POST
  @Path("/create")
  @Produces({MediaType.APPLICATION_JSON})
  public Playlist createPlaylist(@FormParam("name") String name)
  {
      Playlist p = playlistDao.create();
      p.setName(name);
      playlistDao.insert(p);
      return p;
  }
  </code></pre>
  
  <p>I want the "name" parameter to come from the form OR from the query parameter. If the user posts to /playlist/create/?name=bob then I want it to work. (This is mostly to aid with testing the API, but also for consuming it on different non-browser platforms.) </p>
  
  <p>I'd be willing to subclass whatever makes the magic binding work... (@BothParam("name") String name) but would need some help to make that happen as I'm new to Jersey/Java Servlets.</p>
  
  <hr>
  
  <p>Update: The next day...</p>
  
  <p>I've solved this by implementing a ContainerRequestFilter that merges the form parameters into the query parameters. This isn't the best solution, but it does seem to work. I didn't  have any luck merging anything into the form parameters. </p>
  
  <p>Here's the code in case someone comes looking for it:</p>
  
  <pre><code>@Override
  public ContainerRequest filter(ContainerRequest request) 
  {
      MultivaluedMap&lt;String, String&gt; qParams = request.getQueryParameters();
      Form fParams = request.getFormParameters();
      for(String key : fParams.keySet())
      {
          String value = fParams.get(key).get(0);
          qParams.add(key, value);
      }
  }
  </code></pre>
  
  <p>I would still appreciate knowing if there is a better way to do this so I'll leave this question open for now.</p>