i think you may use scope="request" or scope="page", because when scope is
session only one instance of the bean is created...


s.b.

>From: Nitin Khattar <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Multiple instances of the same Bean id ?
>Date: Thu, 28 Sep 2000 16:19:52 +0530
>
>Hi
>
>Following is the Code of a jsp and a Bean. Its a simple jsp which displays
>the 'count' property of bean.
>
>The problem is that when you refresh simple.jsp it does not increase the
>value of 'count'. However if i make 'count' as a static field (in the bean)
>the value of count increases for each refresh indicating that a separate
>instance of the same bean is created on each refresh.
>
>where as i expected the same instance of the bean to be called for each
>refresh.
>
>can somebody explain this behaviour?
>
>thanks
>Nitin
>
>Code in simple.jsp
>
><jsp:useBean id="x" scope="session" class="projsp.Simple" />
>
><html>
><body>
>Count is = :
><jsp:getProperty name="x" property="count" />
></body>
></html>
>
>CODE IN Simple.java
>
>package projsp;
>public class Simple {
>
>private int count;
>
>public void setCount(int c){
>    count=c;
>}
>
>public int getCount(){
>     count++;
>   return count;
>}
>}
>
>===========================================================================
>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

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

===========================================================================
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

Reply via email to