Re: JSR311: _at_Cookie

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 12 Feb 2008 10:45:09 -0500

On Feb 11, 2008, at 6:24 PM, Dhanji R. Prasanna wrote:
> On Feb 12, 2008 8:31 AM, Bill Burke <> wrote:
> I think some form of @Cookie injection would be useful:
> @GET
> public String get(@Cookie("myCookie") int value)
> {
> }
> Would save a lot of typing. The only problem I see with this is
> that it
> overloads with Maybe rename the object to
> CookieInstance?
> I'm thinking you could also do:
> @GET
> public String get(@Cookie("myCookie") CookieInstance instance){}
> Hmm. Not a bad idea. Why not:
> public Response get(@Param("cookieName") javax.servlet...Cookie
> cookie);
> ?
Do you mean @HeaderParam or a new annotation @Param ?

We've also had a request for @PostParam/_at_FormParam to allow extraction
of parameters from posted form data.

I wonder if there's a way to unify all of this somehow like we did for
method designators by making @HttpMethod a meta annotation. Something

public @interface RequestParam {
     public enum Source {HEADER, QUERY, MATRIX, PATH, COOKIE, FORM};
     Source source();

and then we could redefine our existing XXXParam annotations using
this new meta annotation, e.g.:

public @interface QueryParam {
     String value();

Not sure if this really helps, it does allow others to define their
own annotations but the list of sources is still fixed.

Thoughts ?


Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.