/** Cracks the command and invokes the appropriate next screen */ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { // Sets up session tracking ServletContext context = getServletContext(); HttpSession session = req.getSession(); // Gets command, which says what button was pressed String command = req.getParameter("command"); if (command == null) { Util.putMessagePage(res, "Please go back and use a button"); return; } // "Exit" invalidates the session if (command.equals("Exit")) { Util.exitSession(session, res); return; } // "Relogin" invalidates the session and starts over if (command.equals("Relogin")) { session.invalidate(); RequestDispatcher dispatcher = context.getRequestDispatcher(Util.BASE + "index.jsp"); dispatcher.forward(req, res); return; } // At this point the session may be new, or may be already // validated. If session is not valid, or if a login was // specified, do a dbt database login, and validate the // user's login. if (!Util.isSessionValid(session, null) || req.getParameter("Username") != null) { if (!createDbConnection(session, req, res)) return; if (!validateLogin(session, req, res)) return; } // Shows the DBT_DB records if (command.indexOf("Databases") > -1) { RequestDispatcher dispatcher = context.getRequestDispatcher(Util.BASE + "ShowDbs.jsp"); dispatcher.forward(req, res); return; } // Displays all the history records if (command.indexOf("History") > -1) { RequestDispatcher dispatcher = context.getRequestDispatcher(Util.BASE + "ShowHistory.jsp"); dispatcher.forward(req, res); return; } // Changes the user's password if (command.indexOf("Password") > -1) { RequestDispatcher dispatcher = context.getRequestDispatcher(Util.BASE + "ChangePassword.jsp"); dispatcher.forward(req, res); return; } // Performs admin functions if (command.indexOf("Admin") > -1) { RequestDispatcher dispatcher = context.getRequestDispatcher(Util.BASE + "AdminFnc.jsp"); dispatcher.forward(req, res); return; } Util.putMessagePage( res, "<p>Dbtracker internal error<p>Unknown command in " + getServletInfo()); } catch (ServletException e) { throw e; } catch (IOException e) { throw e; } catch (Throwable t) { Util.putExceptionPage(res, t); } }