I have a question about reuse of servlet instances.  The base class,
Servlet, returns true for the method canBeReused().  This is the
default and no subclass appears to override this.  Yet, in
Page.awake(), the attributes of the transaction are stuffed into
self:

  def awake(self, transaction):
      HTTPServlet.awake(self, transaction)
      self._transaction = transaction
      self._response    = transaction.response()
      self._request     = transaction.request()
      self._session     = None  # don't create unless needed
      ...

  def request(self):
      return self._request

  ...

What happens then on a heavily loaded system when 100s or more are
hitting the same Servlet?  Could this not lead to disaster if in my
code I always refer to self.request() to get the request object?
Couldn't one request overwrite another?

My assumptions about caching data:

   1. Use sessions for data meaningful to a user across multiple Servlet
      requests
   2. Use fields (of the request object) for data meaningful for a
      single request (e.g., in awake(), stuff the request object with
      info needed in respond().
   3. Use instance attributes for data meaningful across all sessions and
      requests.

Placing transaction data in the Servlet instance definitely breaks my
third assumption.

Comments please!

Daniel Popowich
Wordbox, Inc.


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to