> Derek Conniffe wrote:
>
> Hi Everyone,
>
> I'm having Session handling problems.
>
> I have now built a number of Beans which look after database access.
> The Beans do all the database interactions within the "processRequest"
> public method & then there are a number of "set", "get" and "is" methods
> which the JSP pages use to set (via. A HREF's & FORM METHODS) and get
> data for display.
>
> The "processRequest" public method loads up the [database] results into
> private class variables which are shared by all the public methods.

I assume you mean instance variables, not class (static) variables? Class
variables are shared by all instances and would produce the behavior
you're describing.

> My problem is that after the "processRequest" method is executed all sessions
> (Browsers ON DIFFERENT Computers) retrieve the same data from the "get"
> methods of the Bean.  There appears to only be one instance of a Bean at any one
> time & data seems to be shared accross all users.

Since you're talking about the processRequest method you must be using
a JSP 0.92 implementation. In JSP 0.92 "scope" is called "lifespan", so
your USEBEAN tag should look something like this:

  <USEBEAN NAME="dbBean" TYPE="com.mycomp.DbBean" LIFESPAN="session">

A separate instance per session should then be created. If that's not
what you see the JSP engine you're using is broken.

> With Servlets it is up to the programmer to utilise the
> "request.getSession(true)" method to track & control sessions.  Is this
> still the case with JSP/Bean programming?  If so how do you hold data (other
> than private class variables) for retriving by individual sessions?

You shouldn't have to do this. Using LIFESPAN="session" saves and retrieves
the Bean from the session for you.

If you still have problems with this, I'm sure you would get more help
if you included more information with your question, such as which JSP
version your using (I could guess that it's 0.92 but I shouldn't have to),
which implementation (reference, a specific commercial version), and
code snippets (the USEBEAN tag, pieces of the JavaBean). In other words,
make it easy for readers to answer your questions and the amount and
quality of the replies will increase.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to