public String getCategories(String regionName, String username, String password)
public String getCategories(String regionName, String username, String password) throws RemoteException
  public String getCategories(String regionName, String username, String password)   {    Collection list;    Category cat;    CategoryHome home = null;    String html = "";    int regionId = -1;    int userId = -1;    if (regionName != null && regionName !="")    {      // Connecting to region Home interface thru JNDI      RegionHome regionHome = null;      try       {        regionHome = (RegionHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Region"),                                                       RegionHome.class);      }       catch (Exception e)      {        throw new EJBException("Cannot lookup Region: " +e);      }      // get the region ID      try      {        Region region = regionHome.findByName(regionName);        regionId = region.getId().intValue();      }      catch (Exception e)      {        throw new EJBException(" Region "+regionName+" does not exist in the database!<br>(got exception: " +e+")");      }    }    else    {      // Authenticate the user who wants to sell items      if ((username != null && username !="") || (password != null && password !=""))      {        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         {          userId = auth.authenticate(username, password);        }         catch (Exception e)        {          throw new EJBException("Authentication failed: " +e);        }        if (userId == -1)        {           html = (" You don't have an account on RUBiS!<br>You have to register first.<br>");           return html;        }      }    }    // Connecting to Category Home    try     {      home = (CategoryHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Category"), CategoryHome.class);    }     catch (Exception e)    {      throw new EJBException("Cannot lookup Category: " +e);    }    utx = sessionContext.getUserTransaction();    try     {      utx.begin();      list = home.findAllCategories();      if (list.isEmpty())        html = ("<h2>Sorry, but there is no category available at this time. Database table is empty</h2><br>");      else      {        Iterator it = list.iterator();        while (it.hasNext())        {          cat = (Category)it.next();          if (regionId != -1)          {            html = html + printCategoryByRegion(cat, regionId);          }          else          {            if (userId != -1)              html = html + printCategoryToSellItem(cat, userId);            else              html = html + printCategory(cat);          }        }      }      utx.commit();    }     catch (Exception e)     {      try      {        utx.rollback();        throw new EJBException("Exception getting category list: " + e);      }      catch (Exception se)       {        throw new EJBException("Transaction rollback failed: " + e);      }    }    return html;  }