On May 15, 5:00 pm, BurstUser <saurabhjo...@gmail.com> wrote: > Hi all, > > Using GWT, I'm trying to call two methods which exist in a > RemoteService from my entrypoint class. > I have two methods within my remoteService servlet, method A and > method B. > > Method A returns an int and sets an arraylist. > Method B returns the arraylist, myList. > I'm assuming that a single callback is associated with a single > servlet method? Is it possible to access the arraylist, which has been > set from calling method A, using the callback?
In general, servlets should not hold any static non-constant data at all. Many people on many machines will browse to your web application, and many of them might be executing the same service at once. Also, you have no control over the threading. The Java container may create many instances of your class and access them through many threads. You did declare the list as a static variable, so the number of objects does not matter. However, the threading does. I supposes you could use classes in java.util.concurrent, but you don't really want to do that. Just imagine what could happen with two users: User 1 calls method A, and the list is set to list 1. User 2 calls method A, and the list is set to list 2. User 1 calls method B, and list 2 is returned, while list 1 would have been correct. You could have method A return an appropriate key for your database, and the B service have a method with signature List<Item> items(Key key) where 'key' is what was returned by the method A. I've used a specific class instead of 'int' here. Respectfully, Eric Jablow -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.