UserHome uHome; try { userId = new Integer (uid); uHome = (UserHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/User"), UserHome.class); } catch (Exception e) { throw new EJBException("Cannot lookup User: " +e+"<br>"); } try { User u = uHome.findByPrimaryKey(new UserPK(userId));
UserHome uHome; try { userId = new Integer (uid); uHome = (UserHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/User"), UserHome.class); } catch (Exception e) { throw new RemoteException("Cannot lookup User: " +e+"<br>"); } try { User u = uHome.findByPrimaryKey(new UserPK(userId));
  public String getAboutMe(String username, String password)   {    int uid = -1;    Integer userId;    String html = "";    // Authenticate the user    SB_AuthHome authHome = null;    SB_Auth auth = null;    try     {      authHome = (SB_AuthHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/SB_Auth"), SB_AuthHome.class);      auth = authHome.create();    }     catch (Exception e)    {      throw new EJBException("Cannot lookup SB_Auth: " +e);    }    try     {      uid = auth.authenticate(username, password);    }     catch (Exception e)    {      throw new EJBException("Authentication failed: " +e);    }    if (uid == -1)    {      html = (" You don't have an account on RUBiS!<br>You have to register first.<br>");      return html;    }    // Try to find the user corresponding to the userId      UserHome uHome;      try       {        userId = new Integer (uid);        uHome = (UserHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/User"), UserHome.class);      }       catch (Exception e)      {        throw new EJBException("Cannot lookup User: " +e+"<br>");      }      try      {        User u = uHome.findByPrimaryKey(new UserPK(userId));        html = u.getHTMLGeneralUserInformation();      }      catch (Exception e)      {        throw new EJBException("This user does not exist (got exception: " +e+")<br>");      }      // Try to find the comments corresponding for this user      CommentHome cHome;      try       {        cHome = (CommentHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Comment"), CommentHome.class);      }       catch (Exception e)      {        throw new EJBException("Cannot lookup Comment: " +e+"<br>");      }      // Retrieve ItemHome      ItemHome iHome;      try       {        iHome = (ItemHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Item"), ItemHome.class);      }       catch (Exception e)      {        throw new EJBException("Cannot lookup item: " +e+"<br>");      }      // Connecting to Query Home thru JNDI      QueryHome qHome;      try       {        qHome = (QueryHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Query"), QueryHome.class);      }       catch (Exception e)      {        throw new EJBException("Cannot lookup Query: " +e+"<br>");      }      try       {        html = html.concat(listItem(userId, iHome));        html = html.concat(listBoughtItems(userId, iHome));        html = html.concat(listWonItems(userId, iHome, qHome));        html = html.concat(listBids(userId, username, password, iHome, qHome));        html = html.concat(listComments(cHome, userId, uHome));              }       catch (Exception e)      {        throw new EJBException("Cannot lookup Query: " +e+"<br>");      }     return html;  }