This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I know servlets are persistent. It retains some data in its memory,so it avoids frequent disk access against the database. Which is the memory of servlet? ie. how servlets are persistent? Because of using session variables?
I'm not sure I understand your question correctly, but servlets are not persistent, they should be 'effectively stateless', that is any state they require internally should be treated as a constant and not be able to change, and idealy this state would be set on the ServletContext and not the Servlet itself.
Joined: Apr 04, 2006
yes,ofcourse. Using ServletContext,servlet can retain a constant value and share it with other servlets also. then we can say it as persistent but u say it s not.what s the reason for that? which thing we shud say as persistent? Connecting to database only? pls clarify.
As I said, the servlet does not retain any state itself, it allows any state it requires to be retained elsewhere, outside the servlet itself. Likewise, the servlet should not (or in this case must not) maintain state such as Database connections. In the case of DB connections it is dangerous and wasteful, and Connection Brokers do the job much beter.