The data used by the application can be externalized into other objects (with in particular database connectors explained latter).
- Adding data from other objects
To make the appplication more rationale, a new class modeling a simplified database (DB) is introduced.
Notice that this one is put into the "lib" directory ; this is because "jar" and applications' extensions are put here.
a. UsersDB class
mkdir WEB-INF/lib/db # package under construct
cat > WEB-INF/lib/db/UsersDB.java << EOF
package db;
import java.util.ArrayList;
public class UsersDB {
public class User {
public String name,mark;
public User(String n, String m) { name=n; mark=m; }
public String getName() { return name; }
public String getMark() { return mark; }
}
public ArrayList<User> users = new ArrayList<User>();
public UsersDB() {
users.add(new User("bill","13"));
users.add(new User("kate","18"));
}
}
EOF
Next, the code is compiled and put into a package.
javac WEB-INF/lib/db/*.java
cd WEB-INF/lib; jar cvf db.jar db/*; cd ../..
9 - 16
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented