import java.servlet.*; import java.io.*; import java.util.*; import java.servlet.http.*; import java.lang.*; import java.lang.Thread.*; public class Ubiq extends GenericServlet { String Version = "2.4"; //Password is an attempt to prevent other classes //from accessing the data inside the User Data I/O class private String systemPassword = "KJaslkjdKDDShLBUasdf2837skdj"; BDUserData sysusers = new BDUserData(); Loop loop = new Loop(); ////////////////////////////// public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintStream out = new PrintStream(res.getOutputStream()); String systemcall = req.getURLLine(); runCall(systemcall, out); } ////////////////////////////// //each call is basically the parameter to the servlet from //the URL. Example: http://www.server.com/scm/kill //calls the stopService function public void runCall(String call, PrintStream out) { if (call == "scm/kill") stopService(out); else if (call == "scm/load") loadUsers(out); else if (call == "scm/save") saveUsers(out); else if (call == "scm/stop") stopLoop(out); else if (call == "scm/start") startLoop(out); else if (call == "user/load") loadUser(out); else if (call == "user/new") newUser(out); else default(out); } ////////////////////////////// public void stopService(PrintStream out) { destroy(); } ////////////////////////////// public void loadUsers(PrintStream out) { sysusers.initialize(systemPassword); } ////////////////////////////// public void saveUsers(PrintStream out) { sysusers.saveData(systemPassword); } ////////////////////////////// public void stopLoop(PrintStream out) { loop.stopMotion(); loop.stop(); } ////////////////////////////// public void loadUser(PrintStream out) { request_password(); // not implemented here printform(); // not implemented here } ////////////////////////////// public void newUser(PrintStream out) { printformnewuser(); // not implemented here addUser(); // not implemented here } ////////////////////////////// public void default(PrintStream out) { writeHeader(out); startLoop(out); writeData(out); write Footer(out); } ////////////////////////////// public void writeDate(PrintStream out) { Date today = new Date(); out.println("