• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WOA, Building a Login form
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOA, Building a Login form


  • Subject: Re: WOA, Building a Login form
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 4 Apr 2005 00:51:17 +0200

Drew,

On 4.4.2005, at 0:32, Drew Thoeni wrote:

Myself, I tend to use something like this (with the very same disclaimer: there may be much better way still :))

	public WOComponent logout() {
		session().terminate();
		WORedirect wor=new WORedirect(context());
		wor.setUrl(context().directActionURLForActionNamed("default",null));
		return wor;
	}

Yes. I agree. Oddly, I had not thought about this, but I am both nullifying the session.user and terminating the session. Upon reflection, I suppose I can just do the latter.

In principle, you sure do.

In a particular application there *may* be a world of difference in that other methods are called before the session dies (it does not, of course, at the moment of the terminate() call, but at the end of the R/R loop). Those methods *may* behave quite different way if the current user is null and if it is not.

And, I have an outstanding question to myself whether this is just making a reference, or really copying the data.

Uh-oh? *All* Java objects are references, if that's what we are speaking of. To copy one, you have to do that manually (like by using the clone method).

That seemed to be the case and you and Sacha point this out. My concern, on this question is exhibited in this snippet:


Object a = new Object(); // assume values populated after instanation
Object b = new Object(); // assume empty

What does it mean, populated/empty? What is populated and how, what is empty and what does it mean?


b = a; // assume a is garbage collected because it was build inside a method

So, the question is, when "a" goes away does "b" become null?

Well, this is some Java (or rather, object-oriented-paradigma) 101, I guess :))


Of course not. Nothing ever becomes null "just by itself", unless you make it so :) Let's make it slightly more obvious by distinguishing them objects from them variables:

Object a/*this is "variable a"*/=new Object()/*this is "object A"*/;
Object b/*this is "variable b"*/=new Object()/*this is "object B"*/;

Now, there are two variables (from all practical points of view just plain pointers, they contain just memory addresses, that's all), a and b. There are two objects (chunks of memory with a well-known structure and implicitly assigned functionality), A and B. The variable a contains the address of the object A. The variable b contains the address of the object B.

b=a;

now, both the variables contain the same address, the address of the object A (that's exactly what we directed the JVM to do by the assignment -- to copy the address from the variable a into the variable b). Therefore, there are two variables now, a and b, both of them with the very same contents, which is the address of A.

The object B gets unreferenced by anybody. Which means that the garbage collector would, sooner or later, eat it and remove it. Therefore, (in some future--not necessarily immediately) we have just one object here, which is A.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >WOA, Building a Login form (From: Amedeo Mantica <email@hidden>)
 >Re: WOA, Building a Login form (From: Drew Thoeni <email@hidden>)
 >Re: WOA, Building a Login form (From: Amedeo Mantica <email@hidden>)
 >Re: WOA, Building a Login form (From: Drew Thoeni <email@hidden>)
 >Re: WOA, Building a Login form (From: Ondra Cada <email@hidden>)
 >Re: WOA, Building a Login form (From: Drew Thoeni <email@hidden>)

  • Prev by Date: Create&initialize a session programmatically?
  • Next by Date: Re(2): Javascript Error onBlur
  • Previous by thread: Re: WOA, Building a Login form
  • Next by thread: Re: WOA, Building a Login form
  • Index(es):
    • Date
    • Thread