import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import MDMSupport.*; public class deleteBuddyForUser 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 Get request public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try{ String userName = request.getParameter("userName"); String buddyId = request.getParameter("buddyId"); dbm.deleteBuddy(userName, buddyId); response.setStatus(response.SC_NO_CONTENT); } 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(); } } public void destroy(){ try{ dbm = null; } catch(Exception ex){ ex.printStackTrace(); } } //Get Servlet information public String getServletInfo() { return "deleteBuddyForUser Information"; } }