/** * Sell a current holding of stock shares for the given trader. Dispatch to the Trade Portfolio * JSP for display * * @param userID The User buying shares * @param symbol The stock to sell * @param indx The unique index identifying the users holding to sell * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @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 doSell( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, Integer holdingID) throws ServletException, IOException { String results = ""; try { OrderDataBean orderData = tAction.sell(userID, holdingID, TradeConfig.orderProcessingMode); req.setAttribute("orderData", orderData); req.setAttribute("results", results); } catch (java.lang.IllegalArgumentException e) { // this is a user error so I will // just log the exception and then later on I will redisplay the portfolio page // because this is just a user exception Log.error( e, "TradeServletAction.doSell(...)", "illegal argument, information should be in exception string", "user error"); } catch (Exception e) { // log the exception with error page throw new ServletException( "TradeServletAction.doSell(...)" + " exception selling holding " + holdingID + " for user =" + userID, e); } requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.ORDER_PAGE)); }