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