RE: About the Session ObjectRepository
"Christian Cryder" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Ming, First the brief answer...You will never need to call setupSessionRepository...that happens behind the scenes for you already. So all you have to do is check to see if the value exists in the session...if it comes back null, that means it doesn't (ie. they are not logged on). So as soon as they have sucessfully logged on, all you have to do is place the value in their session (using the Session ObjectRepository), and then the next time they request something, that value will be there. Now some additional detail...The session repository is actually pretty smart. You don't want to create a session for every single request that comes in, otherwise someone could quickly run your webapp out of memory simply by making a whole bunch of requests from different servers. So really, we only want to create the session after we have verified that we are dealing with a valid user. At the same time, we won't know if we're dealing with a valid user until we check the session. Now, this sounds kind of like a catch-22 situation, but its actually not. The session repository effectively wraps the real http session, so that the real session does not actually get created until we actually try and put something into it. In other words, simply checking to see if the session holds a value will always return false if the session does not yet exist. This keeps the overhead minimal for bogus requests. The session only gets created when you actually put a value into it (ie. because the user sucessfully logged on). That make sense? Holler if you need further explanation! Christian ---------------------------------------------- Christian Cryder Internet Architect, ATMReports.com Project Chair, BarracudaMVC - http://barracudamvc.org ---------------------------------------------- "Coffee? I could quit anytime, just not today" -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Ming Peng Sent: Friday, June 27, 2003 1:42 AM To: [email protected] Subject: [Barracuda] About the Session ObjectRepository Dear Sir I have a question on the "ObjectRepository".Sometimes,I want to check whether the user ,who just made the request, has login in by the HttpSession.If not,when I call the "ObjectRepository.getSessionRepository()",what will I get?A "null"?And if I want to setup a new session for a user,I must call the "ObjectRepository.setupSessionRepository(HttpServletRequest req)"---is that right? Sorry for my poor English.And thanks for your answer or any hints.