users@jersey.java.net

Variable changes do not happen

From: Muhra Daniel <daniel.muhra_at_googlemail.com>
Date: Sun, 6 Jun 2010 14:53:24 +0200

Hi,

I'm pretty new to all REST and Jersey stuff, but I'm already playing around with it. So far, I got it all working, but one problem is driving me nuts:

Assume having a resource, which as a String member variable. Now I have one method to change it and another one to get the current value.
If I first change the value, it seems, like it's working, but when I check it again using the get method, it still gives me the old value? Why is that the case? And how could I resolve it.
Btw. It seems, that creating new Objects works fine (e.g. adding new Objects to a List), but simple value changing seems to be discarded.

Below is a piece of the example I described:

@Path("/string")
class StringTester{

        private String info;

        public StringTester(){
        
                info = "Foo";
        }

        @GET
        @Path("/set/{value}")
        @Produces(MediaType.TEXT__PLAIN)
        public String setString( @PathParam("value") String value ){
                this.info = value;
                return this.info;
        }

        @GET
        @Path("/get")
        @Produces(MediaType.TEXT__PLAIN)
        public String getString(){
                return this.info;
        }
}

Cheers,
Nostradani