this question has answer here:
i want create array of camera object, defined java class. object shared servlets in web app, , want initialized when server started, not when load servlets. how go doing it?
my initializations:
public camera[] dummycams = new camera[5]; dummycams[0] = new camera("pcam", 640, 480); dummycams[1] = new camera("icam", 641, 481); dummycams[2] = new camera("acam", 642, 482); dummycams[3] = new camera("hcam", 643, 483); dummycams[4] = new camera("mcam", 644, 484);
i using glassfish server, java ee7.
you can add array in servletcontext.
you can use servletcontextlistener listen when servlet context initialization event , retrieve servletcontext , add array it.
you can go through api here servletcontextlitener
Comments
Post a Comment