|
> From: Joel R. Cochran > > I do have one remaining question... why have a Storage object at > all? Right > now I am storing all my needed objects in the session. Doesn't using a > Storage object simply add an unnecessary layer? Well, since the session uses a Hashtable, it has to do a lookup every time I try to get a value from it. If I only get one value (the storage object) at the beginning of the request, and then use setters and getters from that point on, I don't have to do any more lookups. More importantly, though, is its the first step towards the other model I was talking about where you will create a servlet proxy. Your code will end up looking like this: --------- public void doPost(HttpServletRequest req, HttpSerlvetResponse res) throws WhateverExceptionsTheyThrow { HttpSession session = req.getSession(); MyProxy proxy = (MyProxy) session.getValue("MYPROXY"); proxy.doRequest(req, res); } --------- Since the proxy variable is threadsafe, that means the MyProxy class can have instance variables, whatever. Not only that, it's relatively easy to access it with external events (such as timeouts). You'll have one central Collection somewhere with all your sessions, allowing you to display, modify, and cancel sessions with ease. Or so it's said <grin>. I'm currently implementing just this model; I'll let you know how it goes. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.