Carl Desborough

+ Follow
since May 08, 2000
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carl Desborough

Congratulations Alvin ... that's a good score and well deserved ... and thanks for the plug.
14 years ago
You can use the useBean tag to create a javabean object (or retrieve an existing one from the request or session or application associcated with the jsp page) ... you can then execute methods on the bean you retrieve by including java code in your jsp, eg:
<%= mybean.getValue() %>
20 years ago
famous? no ... but yes i did get 100% in scjp and i am from australia.

Originally posted by maha anna:
Are you the famous 100% SCJP from AUS ? Just curious.
maha anna

20 years ago
I dont know of any connection (other than the name) between servlet and initial contexts ...
InitialContext is where you can get register and get access to objects in JNDI.
ServletContext allows a servlet to communicate with its container. Objects can be stored in and retrieved from a ServletContext (set and getAttribute) but i dont think its related to the InitialContext names.
20 years ago
you could have a thread that sleeps for a long time .. wakes up every so often and gets a new (the current time) ... and compares it to the last time it ran the schduled service to see whether it should run another one
20 years ago
Cloneable is used to identify a class that can be cloned ... Object's clone method will thrown an exception if you call it on an object that does not implement cloneable.
The situation is similar for Serializable ... they both say its ok to do something to objects of this class.
As an aside, another legitimate use for an interface with no methods is for storing global constants (public static final data members).
20 years ago
ok for "find all attr2 for a given attr1" with the return values sorted, i would use:
a map from attr1 -> a TreeSet of matching attr2 values.
The treeset will be sorted by the natural ordering of the attr2 values, but if you need a different ordering, you can write your own Comparator for it.
Another consideration is what to return from the get method ... some choices are: a collection, an iterator or an Attr2[].
hmmm now ive lost the original message ... i think you also wanted to be able to "find all attr2 for a given attr1" ... so you could use the same approach in reverse for that.

So your class would look something like:
public class Stuff {
private Map attr1ToAttr2 = new HashMap(); // unsorted
private Map attr2ToAttr1 = new HashMap(); // unsorted
public void add( Attr1, Attr2 );
public Iterator listAttr2( Attr1 );
public Iterator listAttr1( Attr2 );
Well thats how id do it anyway.

ps. Hi Jim
20 years ago
hmmm good question .... i think its a sensible separation of responsibilities ...
the remote interface represents a particular business object (instance) and has methods for things you might want to do to that object, eg [account for Mr Davis.addMoney()],[account for Mr Jones.subtractMoney()].
the home interface represents a directory/factory of all the business objects of that type, eg. [bank.give me Mr Davis's account()]
There are probably technical issues behind it too, but from an object modelling point of view, the above separation of responsibilities makes sense to me.
Im not sure what you are asking
A class with those two attributes in it is easy, but probably not what you want .. if you are thinking about using a collection you probably want to do something like "find all attr2 that have attr1" ... and to do that i would use:
a HashMap with key attr1 and value=a vector of attr2s
You need to think about what functions you want on the class before you can decide how to implement it.

20 years ago
well i cant say 'exactly' what they mean, but roughly speaking:
scalable means you can make it bigger without it breaking.
deployment refers to one of the roles defined in the ejb specification ... the deployer is the person who takes a bunch of ejbs and makes them operational .. the beans are deployed in an ejb container.
Another option and one that is used frequently in the jdk api is to define both an interface and an abstract implementation of it ... so you get the best of both worlds ... you have both a pure interface and a class that implements a lot of the base functionality in a sensible default manner.
Code that makes use of your objects will use the interface, but you can create subclasses by extending the abstract class without having to redefine all the base functionality in each subclass.

20 years ago
The static singleton pattern described above will usually work ... but one special case where it may not work is for EJBs where the container/server uses multiple JVMs.
The static variables will only be unique inside each of the JVMs so if you have non-final static variables, they may not behave in the way you expect them to when you change their values.

20 years ago
you use Class.forName() to make a jdbc driver available because it does more than just return the class object. Im not sure of the details and someone else can probably fill those in.
From the javadoc:
A call to forName("X") causes the class named X to be initialized.
From the jls:
"20.3.8 public static Class forName(String className)
throws ClassNotFoundException
Given the fully-qualified name of a class, this method attempts to locate, load, and link the class"
20 years ago
Cool ... thank you .. heres the text from the jls ammendment for 1.1:
D.7.3 Getting the Class Object for a Named Class
You can get the Class object for a given type with a new use of the class keyword:
Class threadClass = Thread.class;
Class intClass = int.class;
Class voidClass = void.class;
20 years ago
hmmmm that does work, but where does the static class variable come from ... i would have thought it should be listed as a field in the javadoc entry for the Object class, but it isnt ...
20 years ago