Roger Kjensrud wrote: > Hello, > > I'm new to the JSP and JAVA world, and I'm trying to gain an = > understanding of how different clients are handled, and potential = > dangers of having several simultaneous requests. > > I get the concept of JSPs compiled into a servlet, and that they can = > handle several simultaneous requests by spinning off separate threads. = > My understanding so far is that everything that ends up in the service = > method is local to the request, but class instances of variables and = > methods are shared among all threads, right? Yes, class instances would be shared among all threads that are in the same VM. > > Now, with the inclusion of JavaBeans in the JSP you can set the scope to = > session. This means that one instance of this JavaBean is dedicated to = > the client for the session. Is this a full flegded java object with no = > chance of conflicts between instances for different clients? Are there a = > pool of the JavaBeans in the JSP engine/container? Yes, a bean you instantiate with session scope should never be seen by any other client except the one that originally caused it to be created. You pretty much have to trust your servlet engine to manage this correctly. ServletExec, for example, creates a random, 20-character session ID which uniquely identifies the client. The session ID is stored as a memory-resident cookie in the client. When you use the implicit "session" object in a JSP (or do req.getSession() in a servlet), the engine is responsible for giving you the proper session object. > > If I create another object from some Java class within the JavaBean, = > will that cause any problems for me? Will there be any conflicts between = > clients if I have class variables in this class? Will the JSP = > engine/container instantiate an object for each request or will there be = > some kind of pooling? There's no conflict as long as the new objects are instance variables and not class variables. If it's a class variable, then you would be sharing the object among all instances of the JavaBean. Not sure I understand the last part...the engine won't instantiate an object inside your bean - only your code will do that. But if your bean is session scope, then it will definitely not do it for each request. To really see what is going on, put a System.out.println() in each of your constructors. Hope that helps... Dave F. > > Thanks for any inputs, > > Roger Kjensrud > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets