http - Java servlet shared collection -
this question has answer here:
please me. there way how can use collection shared between servlet instances?
i know can save string in httprequestcontext how can store collection? know use database i'd prefer store in memory
public class servlet extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { context.setattribute("somevalue", "avalue"); // want use collection here } }
thank answers.
you can store in session - quite common. in public static collection in external class - sake of example util.mycollection. careful though, servlets should thread-safe , stateless, latter can considered anti-patttern - can lot of trouble doing this.
Comments
Post a Comment