----------------------------------------------------
Please read the FAQ at <http://java.apache.org/faq/>
It does have a search feature!
We cannot guess what you are trying to do:
#1. Include version numbers for all software.
#2. Include relevant configuration settings.
#3. Include full descriptions of the problem.
Got Linux? Seeing lots of java processes?
<http://java.apache.org/faq/?file=274>
----------------------------------------------------
I have spent the last few days researching a question
and I can't seem to find an answer. I hope someone here
might have some insight.
I have a series of servlets that all use information
provided by a HttpSession object. The pseudo code goes like
this:
[Note, 'User' is a serializable class]
Class Login extends HttpServlet {
doGet(req,res) {
getSession(true)
Validate username/password
if(good) {
User u = getUser(username)
session.putValue("user", u)
res.sendRedirect(Options)
}
}
}
Class Options extends HttpServlet {
doGet(req,res) {
getSession(false)
User u = (User)getValue("user")
Validate u
if(good) {
welcome user
} else {
hit the road
}
}
}
My questions center around the user object, u, in the
above examples. u is a local variable within the scope of
the methods. So, it is thread safe, right?. Each access to
Login would be a different thread, thus, a different instance
of u. However, I am putting u into a session object. When
Options gets u, is it getting a reference to Login's u object?
Once Options is run, Login's u object is no longer in scope, so
the reference won't be valid? If I create a new User object in
Login and add that, will the JVM garbage collect that version
since Login is no longer active? Will other accesses of Login
potentially replace u with new information? If so, then Bob
may be using someone else's information?
I hope everyone is following me here. It's kind
of hard to articulate exactly what my real question is.
I'm trying to figure out how sessions maintain objects. I'm
worried that my session objects might disappear due to garbage
collection or scoping. Thanks.
-Tom
--
+-------------------------------------------------------------------+
+ Thomas M. Sasala, Electrical Engineer [EMAIL PROTECTED] +
+ MRJ Technology Solutions http://www.mrj.com +
+ 10461 White Granite Drive, Suite 102 (W)(703)277-1714 +
+ Oakton, VA 22124 (F)(703)277-1702 +
+-------------------------------------------------------------------+
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]