Section 7.2. Upgrade the Site: Running a Credit Check


7.2. Upgrade the Site: Running a Credit Check

We've added a "Run Credit Check" link to the JAW Motors homepage, as shown in Figure 7-1.

Figure 7-1. JAW Motors homepage


When the user clicks on the "Run Credit Check" link, the Controller routes them to the Run Credit Check page as depicted in Figure 7-2.

Figure 7-2. JAW Motors Run Credit Check page


The user enters his name, Social Security Number (SSN), and email address in the form and presses the "Submit Credit Info" button. When a customer requests a credit check, he won't have to wait for the external credit verification process to complete. The Controller Servlet sends a JMS message asynchronously to back end components that process business logic for the request. The customer gets routed back to the JAW Motors home page and is then free to continue using the JAW Motors web site while the credit check completes in the background.

Now that the web pages are done, we have to add actions to the Controller Servlet for running the credit check. Example 7-1 shows the changes.

Example 7-1. ControllerServlet.java
 public class ControllerServlet extends HttpServlet {     ...     private static final String VIEW_CREDIT_CHECK_FORM_ACTION =                                  "viewCreditCheckForm";     private static final String RUN_CREDIT_CHECK_ACTION = "runCreditCheck";     ...     protected void processRequest(HttpServletRequest request,             HttpServletResponse response)             throws ServletException, IOException {         ...         else if(VIEW_CREDIT_CHECK_FORM_ACTION.equals(actionName))         {             destinationPage = "/creditCheckForm.jsp";         }         else if(RUN_CREDIT_CHECK_ACTION.equals(actionName))         {             System.out.println("Credit Check:\nName = [" +                                 request.getParameter("name") + "]");             System.out.println("SSN = [" + request.getParameter("ssn") + "]");             System.out.println("Email = [" + request.getParameter("email") + "]");             destinationPage = "/index.jsp";         }         ...     }     ... } 

As shown in the web pages, pressing the "Run Credit Check" link on the main page invokes the viewCreditCheckForm action, and the Controller Servlet routes the user to the "Run Credit Check" Form. Pressing the "Submit Credit Info" from the form invokes the runCreditCheck action, and (for now) the Controller Servlet captures the user's credit information and returns them to the main page. Now that we've built the user interface and have the infrastructure in place, we'll keep adding functionality to the runCreditCheck action so we can send a JMS message with the user's credit data.

We now want to wrap the user's credit information in an object and send it as a JMS message. Since the rest of our work depends on JMS, let's take a brief tour through JMS Architecture before we add any more functionality.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net