Rajesh,
You want to use a bean in the session context. So when you do your usebean, set the scope attribute to session. The servlet engine will check to see if there is an instance of the class you're requesting in the session with that id. If there isn't, it will create one using the no-args constructor of your javabean. The session namespace isn't shared (that's what session is all about) - if you set the scope to session you should be creating a new Vector bean for each unique browser (session).
I believe the number of active servlets is left up to the implementer of the engine. It's not an issue you're supposed to have to worry about.
What may be happening is that you're using a bean (or storing an object) with application scope and then referencing that on your jsp pages. This would cause the problem you're describing. Alternatively, if the bean you're instantiating relies on some shared resource (both beans refer to another object that retains the current recordid, for instance) you might run into the same problem as well.
Mike
-----Original Message-----
From: Save, Rajesh (CAP, CARD) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 14, 1999 3:10 PM
To: [EMAIL PROTECTED]
Subject: Sessions ?
Hi,
Can someone explain how the multiple (concurrent) requests are handled
by the Web-server/Servlet-engine with regards to Servlet/JSP/JavaBeans ?
My environment: HP-UX, JRun 2.3.3 (Build-154) as Web server & Servlet
engine.
I have a simple application where a single Servlet is called repeatedly to
(first) query the database and
then to display the results one record at a time. (Bad design ? well, it
was my first app.)
This Servlet makes the Database query and stores records into a Vector,
which are then displayed (one at a time) on successive invocations
depending upon the "Next|Prev" buttons.
I would obviously like each user to be able to make his own query and see
his private results.
If I run this Servlet from one browser and then from another (browser) on
different machine,
I see the same data that is being displayed to the first user. This shows
there is only one instance of Servlet object.
I have NOT used sessions. I believe Sessions are supposed to help here. But
how ?
Do I have to create different Vector per Session-ID or one Servlet object
gets created per session ?
How does it work when I have JSP and JavaBeans ?
How many JavaBeans (objects) are created when I <jsp:useBean /> a JavaBean
at a Request/Session/Application scope ?
I haven't seen ANY talk about it in all the discussion that goes on here or
in any of the examples on the web either.
Is this a no-issue ?
Thanks,
- Rajesh
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
