Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 JSP + EJB instance sharing, between clients

views
     
TSadri4n
post Mar 27 2006, 03:12 PM, updated 19y ago

Running in Circles... Going No Where
******
Senior Member
1,846 posts

Joined: Jan 2003


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.


 

Change to:
| Lo-Fi Version
0.0123sec    0.35    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 01:55 PM