I dono if this is correct but lets share knowledge..I've built an EJB application based on this structure
JSP (Clients) ---> Bean1 -----> Bean2(DB interactions)
So basically all the DB interactions will be done in the Bean2 level. The results are returned in a GlobalObject class which only consist of variables and resultsets. All these variables and resultset in the GlobalObject can be referenced throughout all level JSP/Bean1/Bean2 because it is passed in from JSP level during request/calling the bean methods.
In Bean2, Ive set the GlobalObject var to some value So in JSP I've declared the globalObject in order to use it:
Bean2
---------
public void bean2(String client){
globj.var1 = 'client ' + client;
}
Bean1
---------
public void bean1(String client){
//actually this bean does minimal work and acts as a middleman
bean2.bean2(client);
}
JSP
-----
GlobalObject globj = new GlobalObject();
String client = current.client;
bean1(client);
out.println(globj.var1);
So basically it will set the client name into the variable. The problem which im currently facing is that. Client A invokes this bean so...
globj.var1 = 'Client A'
however when Client B access the same bean he/she still referencing the same instance as Client A. When output to screen Client B is able to print Client A in the globj.var1. How can I make so that all the clients would have their own instances without sharing or interfering with each another.
JSP + EJB instance sharing, between clients