⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordertrackinghtmlaction.java

📁 ejb克斯人随风俗
💻 JAVA
字号:
/* @@copyright $Id: OrderTrackingHTMLAction.java,v 1.1 2003/11/01 00:19:59 gmurray71 Exp $ */package com.sun.j2ee.blueprints.consumerwebsite.actions;import javax.servlet.http.*;import java.util.Collection;import javax.naming.*;import javax.xml.rpc.*;// waf importsimport com.sun.j2ee.blueprints.waf.controller.Event;import com.sun.j2ee.blueprints.waf.controller.web.html.*;//adventure importsimport com.sun.j2ee.blueprints.consumerwebsite.*;// Catalog importsimport com.sun.j2ee.blueprints.catalog.*;/** * Handles responsibilities related to getting HTTP request  * info and making the calls to process the action  */public class OrderTrackingHTMLAction extends HTMLActionSupport{       /**     * Handles the http request and provides an     * appropriate response.     *     * Post-condition: Set the bean with info to populate response.     */    public Event perform(HttpServletRequest request) throws HTMLActionException {                String orderId = null;        OrderDetails result = null;              orderId = request.getParameter("orderId");        // put the orderId in the request to display in the screen        request.setAttribute("orderTrackingId", orderId);        try {            result = this.getOrderDetails(orderId, request);            if (result.getPO() == null) {                throw new OrderNotFoundException("Order Not Found: " + orderId);            }            // places result bean data in the response.            request.setAttribute("orderDetails", result);        } catch(OrderNotFoundException ex) {          System.out.println("OrderTrackingHTMLAction caught the OrderNotFoundException Service Exception");           throw new com.sun.j2ee.blueprints.consumerwebsite.exceptions.OrderNotFoundException("Action error calling ordertracking endpoint " + ex);        } catch(Exception ex) {            System.out.println("OrderTrackingHTMLAction caught an Exception");           throw new com.sun.j2ee.blueprints.consumerwebsite.exceptions.OrderNotFoundException("Action error calling ordertracking endpoint " + ex);        }        return null;    }    /**     * Accesses OrderTracking Web Service endpoint using Jax-rpc     */    private OrderDetails getOrderDetails(String orderId,     HttpServletRequest request) throws Exception {                     Context ic = new InitialContext();        OpcOrderTrackingService opcOrderTrackingSvc =            (OpcOrderTrackingService) ic.lookup("java:comp/env/service/OpcOrderTrackingService");        OrderTrackingIntf port = opcOrderTrackingSvc.getOrderTrackingIntfPort();  String server = (request.getServerPort() != 0) ?      (request.getServerName()+":"+request.getServerPort()) :      (request.getServerName());        ((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,        "http://" + server + "/webservice/OtEndpointBean");        return port.getOrderDetails(orderId);       }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -