In order for the bean to exist between client requests, the client
must have cookies enabled in their browser.  A cookie called
JSESSIONID is how the servlet container tracks a user session.
If the cookie doesn't get sent with the clients request, the clients
session can't be found, so the bean is recreated instead of reused.

Glenn

Nitin Khattar wrote:
>
> 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

--
----------------------------------------------------------------------
Glenn Nielsen             [EMAIL PROTECTED] | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

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