Professional Java Server Programming J2EE Edition Chapter 22 : Development and Deployment Roles Robert David Cowan CS486 April 9, 2001.

Slides:



Advertisements
Similar presentations
JSP and web applications
Advertisements

Welcome to WebCRD.
Development and Deployment Roles Venugopal Pakanati.
Internet Sellouts Final Presentation Enterprise Architecture Group.
JBoss Seam: Contextual Components Jason Bechtel
An introduction to Java Servlet Programming
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Writing Enterprise Applications with J2EE (Fifth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Login Screen This is the Sign In page for the Dashboard Enter Id and Password to sign In New User Registration.
Java: Chapter 1 Computer Systems Computer Programming II Aug
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
4-Tier Model Client Tier Web Tier Business Tier EIS Tier.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Session Beans Overview EJB container Remote Invocation Represent client's access to app Local / Remote speed / flexibility trade-off when to choose local.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
Li Tak Sing COMPS311F. Static attributes in Servlets Since Servlets are also Java classes, you can also use static attributes to store values that can.
Introduction to Java Server Pages (JSPs) Robert Thornton.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
Chapter 5 Being a Web App. Very few servlet or JSP stands alone Many times in our application, different servlets or JSPs need to share information 
J2EE Structure & Definitions Catie Welsh CSE 432
Mark Dixon 1 12 – Java Beans. Mark Dixon 2 Session Aims & Objectives Aims –To cover the use of Java Beans Objectives, by end of this week’s sessions,
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
1 Lecture 16 George Koutsogiannakis/SUMMER 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
A TUTORIAL TO USING EJBs by SHREERAM IYER 09/17/2001.
16-Oct-15 JSP Implicit Objects. 2 JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Java Servlets & Java Server Pages Lecture July 2013.
Fall CIS 764 Database Systems Engineering L7. EJB’s.
Application Specific Module Tutorial Akos Balasko 02/07/
Java Server Pages (JSP)
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
Entity Beans & Persistence Chris Alexander CS 486 Spring 2001.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
©SoftMoore ConsultingSlide 1 Filters. Filters can be used in a web application to intercept, examine, and possibly transform requests or responses associated.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
DEVELOPING ENTERPRISE APPLICATIONS USING EJB
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Enterprise Java Beans N.V.RAJASEKHAR REDDY. Definition of EJB EJBs are the components that are the set of classes and interfaces deployed within a container.
Library Example February 2010 – August 2010
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Chapter 14 Using JavaBeans Components in JSP Documents.
Securing Web Applications Lesson 4B / Slide 1 of 34 J2EE Web Components Pre-assessment Questions 1. Identify the correct return type returned by the doStartTag()
Session Beans & Business Logic CS 486 Sagar Deshpande.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
JSP Based on
EJB Architecture and Design
Java Servlets By: Tejashri Udavant..
Enterprise Java Beans.
Introduction to Session beans
Pre-assessment Questions
Presentation transcript:

Professional Java Server Programming J2EE Edition Chapter 22 : Development and Deployment Roles Robert David Cowan CS486 April 9, 2001

Model-View-Controller Design Models Views View1.jsp View2.jsp View3.jsp Controller Main.jsp Browser Client

Manufacturing App Design Models ManageOrdersManufacture ModelManager (proxy) Views createproduct.jsp createrouting.jsp ….and others Controller RequestProcessor Main.jsp Browser Client

Choices.jsp Choose one of the following actions: Create a sample product Place a sample order Manage orders Manufacture a product for an order

Code for Choices.jsp Choices Wrox Sample Code / J2EE Choose one of the following actions: Create a sample product Place a sample order Manage orders Manufacture a product for an order

Code for Main.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" > <% modelManager.init(config.getServletContext(), session); %> <jsp:useBean id="rp" class="RequestProcessor" scope="session" > <% rp.init(config.getServletContext(), session); %> Model and request session scope.

Code for Main.jsp (cont.) Forward request to RequestProcessor.java (class) = update model and return next view. <% String targetView = rp.processRequest(request); Dispatch the request to the appropriate view. getServletConfig().getServletContext(). getRequestDispatcher(targetView).forward(request, response); %>

Code for RequestProcessor.java class import java.text.DateFormat; import java.util.Date; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import factory.manage_orders.NoSuchOrderException; import factory.manage_orders.NoSuchProductException; import factory.manage_orders.DuplicateOrderException; import factory.manufacture.BadStatusException; import factory.order.OrderNotCancelableException; public class RequestProcessor { private ModelManager mm; private HttpSession session; private ServletContext context; private String stackURL; private DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);

Code for RequestProcessor.java (cont.) public void init(ServletContext context, HttpSession session) { this.session = session; this.context = context; mm = (ModelManager)session.getAttribute("modelManager"); } public String processRequest(HttpServletRequest req) { String selectedURL = req.getPathInfo(); if ((selectedURL == null) || selectedURL.equals( ScreenNames.CHOICES )) { return ScreenNames.CHOICES_URL; } else if (selectedURL.equals( ScreenNames.CHOOSE_FOR_MANUFACTURE )) { String cellName = mm.getCurrentCell(); if (cellName == null) { // requires "log on" stackURL = ScreenNames.CHOOSE_FOR_MANUFACTURE_URL; return ScreenNames.CHOOSE_CELL_URL; } Copy model proxy Processing request

Code for RequestProcessor.java (cont.) } else if (selectedURL.equals( ScreenNames.CELL_CHOSEN )) { String cellName = req.getParameter( ScreenNames.CELL_PARAM ); mm.setCurrentCell( cellName ); return stackURL; } else if (selectedURL.equals( ScreenNames.PRODUCT_CREATED )) { String prodID = req.getParameter( ScreenNames.PRODUCT_ID_PARAM ); String prodName = req.getParameter( ScreenNames.PRODUCT_NAME_PARAM ); mm.createProduct( prodID, prodName ); return ScreenNames.CREATE_ROUTING_URL; } else if (selectedURL.equals( ScreenNames.CREATE_ROUTING )) { return ScreenNames.CREATE_ROUTING_URL; } else if (selectedURL.equals( ScreenNames.ROUTING_CREATED )) { String sequence = req.getParameter( ScreenNames.ROUTING_SEQUENCE_PARAM ); String action = req.getParameter( ScreenNames.ROUTING_ACTION_STEP_PARAM ); mm.addRouting( Integer.parseInt(sequence), action ); return ScreenNames.CREATE_ROUTING_URL;

Code for RequestProcessor.java (cont.) } else if (selectedURL.equals( ScreenNames.CANCEL_ORDER )) { String salesDivision = req.getParameter( ScreenNames.SALES_DIVISION_PARAM ); String orderNumber = req.getParameter( ScreenNames.ORDER_NUMBER_PARAM ); String orderType = (req.getParameter(ScreenNames.ORDER_TYPE_PARAM)); try { System.out.println("Request Processor cancel order"); mm.cancelOrder( Integer.parseInt(salesDivision), Integer.parseInt(orderNumber) ); prepareManageOrdersRequest( orderType, req ); return ScreenNames.MANAGE_ORDERS_URL; } catch (OrderNotCancelableException once) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "This order is not cancelable." ); return ScreenNames.MESSAGE_URL; } catch (NoSuchOrderException nsoe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "This order does not exist." ); return ScreenNames.MESSAGE_URL; }

Code for RequestProcessor.java (cont.) } else if (selectedURL.equals( ScreenNames.MANAGE_ORDERS )) { String orderType = (req.getParameter(ScreenNames.ORDER_TYPE_PARAM)); prepareManageOrdersRequest( orderType, req ); return ScreenNames.MANAGE_ORDERS_URL; } else if (selectedURL.equals( ScreenNames.PLACE_ORDER )) { return ScreenNames.PLACE_ORDER_URL; } else if (selectedURL.equals( ScreenNames.ORDER_PLACED )) { try { String salesDiv = req.getParameter( ScreenNames.ORDER_SALES_DIV_PARAM ); String orderNum = req.getParameter( ScreenNames.ORDER_NUM_PARAM ); String productID = req.getParameter( ScreenNames.ORDER_PROD_PARAM ); String dateDueString = req.getParameter( ScreenNames.ORDER_DUE_DATE_PARAM ); Date dateDue = dateFormat.parse( dateDueString ); mm.placeOrder(Integer.parseInt(salesDiv), Integer.parseInt(orderNum), productID, dateDue );

Code for RequestProcessor.java (cont.) req.setAttribute(ScreenNames.MESSAGE_ATTRIB, "Thank you for placing this order." ); } catch (NoSuchProductException nspe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "There is no such product." ); } catch (DuplicateOrderException doe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "There is already an order in that sales division with that number." ); } catch (java.text.ParseException pe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "That is not a valid date." ); } return ScreenNames.MESSAGE_URL; } else if (selectedURL.equals( ScreenNames.ROUTE_FOR_MANUFACTURE )) { if (mm.hasNextRouting()) return ScreenNames.ROUTE_FOR_MANUFACTURE_URL; else return ScreenNames.SHIP_URL; } else if (selectedURL.equals( ScreenNames.SHIP_PRODUCT )) { String loadingDock = req.getParameter(

Code for RequestProcessor.java (cont.) String loadingDock = req.getParameter( ScreenNames.SHIP_LOADING_DOCK_PARAM ); String carrier = req.getParameter(ScreenNames.SHIP_METHOD_PARAM ); mm.shipProduct( carrier, Integer.parseInt(loadingDock) ); return ScreenNames.CHOICES_URL; } else { return ScreenNames.CHOICES_URL; }

Code for RequestProcessor.java (cont.) prepareManageOrdersRequest private void prepareManageOrdersRequest(String orderType, HttpServletRequest req) { if (orderType.equals(ScreenNames.ORDER_TYPE_OVERDUE)) { req.setAttribute(ScreenNames.ORDER_URL_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE); req.setAttribute(ScreenNames.ORDER_ALT_URL_ATTRIB, ScreenNames.ORDER_TYPE_OPEN); req.setAttribute(ScreenNames.ORDER_ALT_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OPEN_TEXT); req.setAttribute(ScreenNames.ORDER_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE_TEXT); Helper method to abstract out some functionality used twice

Code for RequestProcessor.java (cont.) prepareManageOrdersRequest } else // orderType.equals(ScreenNames.ORDER_TYPE_OPEN) ) { req.setAttribute(ScreenNames.ORDER_URL_ATTRIB, ScreenNames.ORDER_TYPE_OPEN); req.setAttribute(ScreenNames.ORDER_ALT_URL_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE); req.setAttribute(ScreenNames.ORDER_ALT_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE_TEXT); req.setAttribute(ScreenNames.ORDER_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OPEN_TEXT); }

Code for ScreenNames.java class public interface ScreenNames { // paths public static final String CHOICES = "/choices"; public static final String CREATE_PRODUCT = "/createproduct"; public static final String CREATE_ROUTING = "/createrouting"; public static final String MANAGE_ORDERS = "/manageorders"; public static final String CHOOSE_FOR_MANUFACTURE = "/manufacturechoose"; public static final String ROUTE_FOR_MANUFACTURE = "/manufactureroute"; public static final String PLACE_ORDER = "/placeorder"; public static final String ORDER_PLACED = "/order_placed"; public static final String PRODUCT_CREATED = "/product_created"; public static final String ROUTING_CREATED = "/routing_created"; public static final String ORDER_CHOSEN = "/order_chosen"; public static final String CANCEL_ORDER = "/cancelorder"; public static final String CELL_CHOSEN = "/cell_chosen"; public static final String SHIP_PRODUCT = "/ship_product"; Constants defined

Code for ScreenNames.java (cont.) // jsps public static final String CHOICES_URL = "/choices.jsp"; public static final String CREATE_PRODUCT_URL = "/createproduct.jsp"; public static final String CREATE_ROUTING_URL = "/createrouting.jsp"; public static final String MANAGE_ORDERS_URL = "/manageorders.jsp"; public static final String CHOOSE_FOR_MANUFACTURE_URL = "/manufacturechoose.jsp"; public static final String ROUTE_FOR_MANUFACTURE_URL = "/manufactureroute.jsp"; public static final String PLACE_ORDER_URL = "/placeorder.jsp"; public static final String MESSAGE_URL = "/message.jsp"; public static final String CHOOSE_CELL_URL = "/cellid.jsp"; public static final String SHIP_URL = "/ship.jsp";

Code for ScreenNames.java (cont.) // parameters public static final String ORDER_TYPE_PARAM = "ordertype"; public static final String ORDER_VIEW_ATTRIB = "order_view"; public static final String ORDER_ALT_VIEW_ATTRIB = "order_alt_view"; public static final String ORDER_ALT_URL_ATTRIB = "order_alt_url"; public static final String ORDER_URL_ATTRIB = "order_url"; public static final String ORDER_TYPE_OPEN = "openorders"; public static final String ORDER_TYPE_OVERDUE = "overdueorders"; public static final String ORDER_TYPE_OPEN_TEXT = "open orders"; public static final String ORDER_TYPE_OVERDUE_TEXT = "overdue orders"; public static final String SALES_DIVISION_PARAM = "salesdivision"; public static final String ORDER_NUMBER_PARAM = "ordernumber"; public static final String MESSAGE_ATTRIB = "message";

Code for ScreenNames.java (cont.) public static final String PRODUCT_ID_PARAM = "product_id"; public static final String PRODUCT_NAME_PARAM = "product_name"; public static final String ROUTING_SEQUENCE_PARAM = "sequence"; public static final String ROUTING_ACTION_STEP_PARAM = "routing"; public static final String ORDER_SALES_DIV_PARAM = "sales_div"; public static final String ORDER_NUM_PARAM = "order_num"; public static final String ORDER_PROD_PARAM = "prod"; public static final String ORDER_DUE_DATE_PARAM = "due_date"; public static final String CELL_PARAM = "cell"; public static final String SHIP_METHOD_PARAM = "shipping_company"; public static final String SHIP_LOADING_DOCK_PARAM = "loading_dock"; }

Code for ModelManager.java class import javax.ejb.EJBException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import javax.servlet.http.HttpSession; import javax.servlet.ServletContext; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import factory.manage_orders.DuplicateOrderException; import factory.manage_orders.OpenOrderView; import factory.manage_orders.OverdueOrderView; import factory.manage_orders.ManageOrders; import factory.manage_orders.ManageOrdersHome; import factory.manage_orders.NoSuchOrderException; import factory.manage_orders.NoSuchProductException; import factory.manufacture.BadStatusException; import factory.manufacture.Manufacture; import factory.manufacture.ManufactureHome; import factory.order.OrderNotCancelableException; Web-tier proxy for EJB-tier

Code for ModelManager.java (cont.) public class ModelManager { private ServletContext context; private HttpSession session; Maintain references to session bean façade. Save persistent Manufacture (stateful) ManageOrder could be reaquired each time for load balancing. private ManageOrders manageOrders; private Manufacture manufacture; private String currentCellID; private String currentProductID; public void init(ServletContext context, HttpSession session) { this.session = session; this.context = context; manageOrders = getManageOrdersEJB(); }

Code for ModelManager.java (cont.) public void createProduct( String productID, String productName ) { try { manageOrders.createProduct( productID, productName ); currentProductID = productID; } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } public String getCurrentCell() { return currentCellID; } public void setCurrentCell( String currentCell ) { currentCellID = currentCell; } public String getCurrentProductID() { return currentProductID; }

Code for ModelManager.java (cont.) public void addRouting( int sequence, String action ) { try { manageOrders.addRoutingInstruction( currentProductID, sequence, action ); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } public void placeOrder(int salesDivision, int orderNumber, String product, Date dateDue ) throws NoSuchProductException, DuplicateOrderException { try { manageOrders.placeOrder( salesDivision, orderNumber, product, dateDue ); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); }

Code for ModelManager.java (cont.) public void cancelOrder( int salesDivision, int orderNumber ) throws NoSuchOrderException, OrderNotCancelableException { try { manageOrders.cancelOrder( salesDivision, orderNumber ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } public synchronized Iterator getOrdersToManufacture() { try { LinkedList list = new LinkedList(); manufacture = getManufactureEJB(); OpenOrderView[] openOrders = manufacture.getOpenOrders(); for (int iter=0; iter<openOrders.length; iter++) { list.add( new OrderView(openOrders[iter]) ); } return list.iterator(); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } synchronization of stateful session bean else illegal multiple concurrent access, stateless does not need it as each access would be directed to a different EJB instance

Code for ModelManager.java (cont.) public synchronized void selectForManufacture(int salesDiv, int orderNum ) throws NoSuchOrderException, BadStatusException { try { manufacture.selectForManufacture( salesDiv, orderNum ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } public synchronized boolean hasNextRouting() { try { return manufacture.hasNextRouting(); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); }

Code for ModelManager.java (cont.) public synchronized String getNextRouting() { try { return manufacture.getNextRouting(); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } public synchronized void shipProduct( String carrier, int loadingDock ) { try { manufacture.ship( carrier, loadingDock ); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); }

Code for ModelManager.java (cont.) public Iterator getOrders(String type) { try { LinkedList list = new LinkedList(); if (type.equals( ScreenNames.ORDER_TYPE_OPEN_TEXT )) { OpenOrderView[] openOrders = manageOrders.getSchedulableOrders(); for (int iter=0; iter<openOrders.length; iter++) { list.add( new OrderView(openOrders[iter]) ); } } else if (type.equals( ScreenNames.ORDER_TYPE_OVERDUE_TEXT )) { OverdueOrderView[] overdueOrders = manageOrders.getOverdueOrders(); for (int iter=0; iter<overdueOrders.length; iter++) { list.add( new OrderView(overdueOrders[iter]) ); } } else throw new IllegalStateException(); return list.iterator(); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); }

Code for ModelManager.java (cont.) helper methods private ManageOrders getManageOrdersEJB() { try { InitialContext initial = new InitialContext(); Object objref = initial.lookup( "java:comp/env/ejb/ManageOrders" ); ManageOrdersHome home = (ManageOrdersHome) PortableRemoteObject.narrow( objref, ManageOrdersHome.class ); return home.create(); } catch (NamingException ne) { throw new EJBException(ne); } catch (java.rmi.RemoteException re) { throw new EJBException(re); } catch (javax.ejb.CreateException ce) { throw new EJBException(ce); }

Code for ModelManager.java (cont.) private Manufacture getManufactureEJB() { try { InitialContext initial = new InitialContext(); Object objref = initial.lookup( "java:comp/env/ejb/Manufacture" ); ManufactureHome home = (ManufactureHome) PortableRemoteObject.narrow( objref, ManufactureHome.class ); return home.create(currentCellID); } catch (NamingException ne) { throw new EJBException(ne); } catch (java.rmi.RemoteException re) { throw new EJBException(re); } catch (javax.ejb.CreateException ce) { throw new EJBException(ce); }

View.java class import java.util.Date; import factory.manage_orders.OpenOrderView; import factory.manage_orders.OverdueOrderView; public class OrderView { private int salesDivision; private int orderNumber; private String product; private String status; private Date dateDue; public OrderView(int salesDivision, int orderNumber, String product, String status, Date dateDue ) { this.salesDivision = salesDivision; this.orderNumber = orderNumber; this.product = product; this.status = status; this.dateDue = dateDue; } public OrderView(OpenOrderView view) { this(view.salesDivision, view.orderNumber, view.product, "open", view.dateDue ); } public OrderView(OverdueOrderView view) { this( view.salesDivision, view.orderNumber, view.product, view.status, view.dateDue ); } Returns information from the model

View.java (cont.) public OrderView() {} public int getSalesDivision() { return salesDivision; } public int getOrderNumber() { return orderNumber; } public String getProduct() { return product; } public String getStatus() { return status; } public Date getDateDue() { return dateDue; }

createrouting.jsp Create a routing for product : Sequence Routing or you can be finished with creating routings for this product.finished with creating routings for this product

Code for createrouting.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> Wrox Sample Code - Create a Routing Create a routing for product : Sequence Routing or you can be finished with creating routings for this product.

placeorder.jsp Place an order for a product: Sales division Order number Product Due date

Code for placeorder.jsp Wrox Sample Code - Place an Order Place an order for a product: Sales division Order number Product Due date

message.jsp Thank you for placing this order. Return to main menu. Thank you message

Code for message.jsp Wrox Sample Code - Message. Return to main menu.

manageorders.jsp Manage Your Orders You are currently viewing. ">Click here to view. Sales Division Order Number ProductDate Due Click to Cancel ">cancel Return to main menu Overdue Order and Open Order

Code for manageorder.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> Wrox Sample Code - Manage Orders Manage Your Orders You are currently viewing. ">Click here to view.

Code for manageorder.jsp (cont.) Sales Division Order Number Product Date Due Click to Cancel <% String orderView = (String) request.getAttribute("order_view"); Iterator iter = modelManager.getOrders( orderView ); while (iter.hasNext()) { OrderView view = (OrderView) iter.next(); %>

Code for manageorder.jsp (cont.) <a href="cancelorder?salesdivision=<%=view. getSalesDivision()%>&ordernumber=<%=view.getOrderNumber() %>&ordertype= ">cancel Return to main menu

manufacturechoose.jsp Choose an order to manufacture: Sales DivisionOrder NumberProductDate Due

Code for manufacturechoose.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> Wrox Sample Code - Select for Manufacture Choose an order to manufacture:

Code for manufacturechoose.jsp (cont.) Sales Division Order Number Product Date Due <% Iterator iter = modelManager.getOrdersToManufacture(); while (iter.hasNext()) { OrderView view = (OrderView) iter.next(); %> <a href="order_chosen?salesdivision=<%=view. getSalesDivision()%>&ordernumber=<%=view.getOrderNumber() %>">

cellid.jsp Login: Enter your current manufacturing cell identification string: First time user will asked to log in

Code for cellid.jsp Wrox Sample Code - Enter Your Cell ID Login: Enter your current manufacturing cell identification string:

manufactureroute.jsp Here is the next step in the manufacture of this product: Solder the lid on the product. Click here when completed.

Code for manufactureroute.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> Wrox Sample Code - Routing Step Here is the next step in the manufacture of this product: Click here when completed.

ship.jsp Ship the manufactured product: Shipping company: Loading dock:

Code for ship.jsp Wrox Sample Code - Ship the Product Ship the manufactured product: Shipping company: UPS Federal Express US Postal Service Private Carrier Loading dock:

index.html Factory Demo for JSPs and EJBs This web site provides a simple interface to the manufacturing example that we developed for the chapters on Enterprise JavaBeans in the Wrox Server Side Java book. See the demo... Welcome screen

Code for index.html Wrox Sample Code - Manufacturing Application <body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000"> Factory Demo for JSPs and EJBs This web site provides a simple interface to the manufacturing example that we developed for the chapters on Enterprise JavaBeans in the Wrox Server Side Java book. See the demo...

Code for web.xml factoryWeb no description entryPoint centralJsp no description main.jsp entryPoint /control/* Web components collected into a JAR with.war (web archive) Archive has web.xml in WEB-INFO directory with welcome, serverlets, mappings and references to EJB

Code for web.xml (cont.) /index.html ejb/ManageOrders Session factory.manage_orders.ManageOrdersHome factory.manage_orders.ManageOrders ejb/Manufacture Session factory.manufacture.ManufactureHome factory.manufacture.Manufacture

Directory Structure cellid.jps choices.jsp createproduct.jsp createrouting.jsp index.html main.jsp manageorders.jsp manufacturechoose.jsp message.jsp placeorder.jsp ship.jsp WEB-INF/ web.xml classes/ ModelManager.class Orderview.class RequestProcessor.class ScreenNames.class

Code for application.xml Factory sample ejbs jsps /factory Web archive added at same level as EJB achive in EAR file. Added to application.xml, assuming EJB JAR in “ejbs” directory and web archive in “jsps”

Troubleshooting Tips 1. Place the jsps folder under the orion\applications\factory directory 2. Replace the application.xml file in orion\applications\factory\META-INF 3. Modify the default-web-site.xml file in orion\config to include a new entry for a web app: 4. Start the orion server and browse to Good Luck with debuggers!

Questions ?