jsp declaration is invoked once when the jsp page is loaded or invoked as per each request?
will result same number on any number of refreshes. same or different browser.
Since it is not static, with every load of the servlet the number would be different, but, Servlets are Singletons, so there is only one instance that is reused for subsequent requests, and therefore your number will not change.
Balu Sadhasivam wrote:
Servlets are Singletons
what ? Servlets are not Singletons just because container creates one instance. Singleton is separate subject.
Whatever way you put it, there is one instance of the Servlet, not more, this is ensured by the container. It is not the fully fledged Singleton pattern, but the idea is the same - One Instance.
Sebastian Janisch wrote:Whatever way you put it, there is one instance of the Servlet, not more, this is ensured by the container. It is not the fully fledged Singleton pattern, but the idea is the same - One Instance.
Firstly, I have to agree with David. Simply creating one instance of a class does not qualify it as a Singleton. That's the name for a distinct pattern.
Moreover, the container can create multiple instances of the Servlet in some circumstances, so even then, the "singleton" moniker is inappropriate.
But all this has nothing to do with the original topic, so if any one wants to pursue the "what is a singleton?" question, please open a new topic in the Patterns forum.
Bear Bibeault wrote:To the original poster: you do realize that scriptlets and scriptlet expressions are no longer deemed acceptable in JSPs, right?
hehe i have recently started studying jsp, so i'm just going ahead and reading whatever comes in the book.
if scriplet and expression are not longer in style, than what are the replacements??
soon i will be start with mvc and javabeans :p using this book (core servlet and javaserverpages volume 1, by core technologies) .....