You need to store each user into a vector and then store the vector as a session variable.
Take a look at java shopping carts for a better understanding
...
public void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session = req.getSession(true);
String username=(String)req.getParameter("username");
if (username==null) { username="";}
Vector allusers=new Vector();
if (!username.equals("")) {
allusers.addElement(username);
allusers = (Vector) session.putValue("getAttribute("cart");
session.setAttribute("AllUsers", allusers);
}
//retrieve
allusers = (Vector) session.getAttribute("AllUsers");
//Error check allusers if more than 0 {
out.println("historic users:");
for (int a=0; a < allusers.size(); a++) {
String users=(String)allusers.elementAt(a);
out.println(users);
}