/** * Login a Trade User. Dispatch to the Trade Home JSP for display * * @param userID The User to login * @param passwd The password supplied by the trader used to authenticate * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @param results A short description of the results/success of this web request provided on the * web page * @exception javax.servlet.ServletException If a servlet specific exception is encountered * @exception javax.io.IOException If an exception occurs while writing results back to the user */ void doLogin( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, String passwd) throws javax.servlet.ServletException, java.io.IOException { System.out.println("Login userID: " + userID); String results = ""; try { // Got a valid userID and passwd, attempt login AccountDataBean accountData = tAction.login(userID, passwd); if (accountData != null) { HttpSession session = req.getSession(true); session.setAttribute("uidBean", userID); session.setAttribute("sessionCreationDate", new java.util.Date()); if (("true").equals(req.getParameter("stress"))) { // fib(35); char[] s = new char[10 * 1024 * 1000]; String str = String.copyValueOf(s); session.setAttribute("someobject", str); } results = "Ready to Trade"; doHome(ctx, req, resp, userID, results); return; } else { req.setAttribute("results", results + "\nCould not find account for + " + userID); // log the exception with an error level of 3 which means, handled exception but would // invalidate a automation run Log.log( "TradeServletAction.doLogin(...)", "Error finding account for user " + userID + "", "user entered a bad username or the database is not populated"); } } catch (java.lang.IllegalArgumentException e) { // this is a user error so I will // forward them to another page rather than throw a 500 req.setAttribute("results", results + "illegal argument:" + e.getMessage()); // log the exception with an error level of 3 which means, handled exception but would // invalidate a automation run Log.error( e, "TradeServletAction.doLogin(...)", "illegal argument, information should be in exception string", "treating this as a user error and forwarding on to a new page"); } catch (Exception e) { doWelcome( ctx, req, resp, "User not found! Is the database <a href = 'config?action=buildDB'>populated </a>?"); return; /* throw new ServletException( "TradeServletAction.doLogin(...)" + "Exception logging in user " + userID + "with password" + passwd ,e); */ } requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.WELCOME_PAGE)); }