import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import MDMSupport.*; public class getInfoAboutUsersAndAdd extends HttpServlet { //Initialize global variables DBServerInterface dbm; public void init(ServletConfig config) throws ServletException { try{ super.init(config); dbm = (DBServerInterface)System.getProperties().get("MDM.DBServer"); } catch(Exception ex){ ex.printStackTrace(); } } //Process the HTTP Post request public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ObjectInputStream ois = new ObjectInputStream(req.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(res.getOutputStream()); try{ Object obj = ois.readObject(); Vector v = (Vector)obj; //The first element should be user name and the rest //are buddies String userName = (String)v.elementAt(0); v.removeElementAt(0); BuddyTableModel btm = dbm.getInfoAboutUsersAndAdd(userName, v); oos.writeObject(btm); v = null; btm = null; } catch(NullPointerException ex){ try{ System.out.println("Recreating connection to FMServer"); org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); dbm = DBServerInterfaceHelper.bind(orb, "DBServer"); System.getProperties().put("MDM.DBServer", dbm); } catch(Exception subEx){ subEx.printStackTrace(); } } catch(ClassCastException ex){ try{ System.out.println("Recreating connection to FMServer"); org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); dbm = DBServerInterfaceHelper.bind(orb, "DBServer"); System.getProperties().put("MDM.DBServer", dbm); } catch(Exception subEx){ subEx.printStackTrace(); } } catch(Exception ex){ ex.printStackTrace(); } finally{ ois.close(); oos.close(); } } public void destroy(){ try{ dbm = null; } catch(Exception ex){ ex.printStackTrace(); } } //Get Servlet information public String getServletInfo() { return "getInfoAboutUsersAndAdd Information"; } }