import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class isUserExisting 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(); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = new PrintWriter (response.getOutputStream()); try{ response.setContentType("text/html"); String userName = request.getParameter("userName"); //JDBC routine to check user exists. If success then return boolean isUserExisting = dbm.isUserExisting(userName); if (isUserExisting){ out.println("Success: Valid user. MDMessenger Initialising..."); } //If routine fails then return failure else{ out.println("Failure"); } } 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{ out.close(); } } public void destroy(){ try{ dbm = null; } catch(Exception ex){ ex.printStackTrace(); } } //Get Servlet information public String getServletInfo() { return "isUserExisting Information"; } }