views:

22

answers:

1

I'm having a heck of a time setting a cookie in restlet, heres what I have so far::

public class CookieTestResource extends ServerResource {

    @Post
    public Representation post(Representation representation){
        CookieSetting cS = new CookieSetting(
                1, 
                "cookieName", 
                "cookieValue"
                );
        Series<CookieSetting> cookies = new Series<CookieSetting>(); //<--PROBLEM
        cookies.add(cS);
        this.setCookieSettings(cookies);
        // SEND RESPONSE
        setStatus(Status.SUCCESS_OK);
        return new StringRepresentation("");
    }
}

The problem that I'm having now is that I can't instantiate a class of type "org.restlet.util.Series" and I can't find any subclasses that I can instantiate. This seems like a dumb problem. but I have no idea what to do. Additionally, I seem to hit this kind of problem with Restlets a lot. Often I can't figure out how to use this tool from the API's and when I search for examples, I find none. Is there some other way I should be referencing documentation on Restlets?

A: 

Here is the answer:

(I was missing the 'getResponse()' in 'this.getResponse().getCookieSettings().add(cS);)

public class CookieTestResource extends ServerResource {

    @Post
    public Representation post(Representation representation){

        CookieSetting cS = new CookieSetting(0, "cookieName", "cookieValue");
        this.getResponse().getCookieSettings().add(cS);

        // SEND RESPONSE
        setStatus(Status.SUCCESS_OK);
        return new StringRepresentation("");
    }
}
DutrowLLC