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

📄 orderparser.jsp

📁 weblogic_src_xml.rar
💻 JSP
字号:
<!-- Copyright (c) 1999-2003 by BEA Systems, Inc. All Rights Reserved.-->

<!-- Here we use a Java string ("PAGETITLE") to set 
     the same phrase as the title and as a head.-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1">
<meta name="description" content="BEA WebLogic Server">

<meta name="keywords" content="BEA WebLogic Server">

<title>Order Parser using XMLInputStream API</title>

<LINK REL="stylesheet" 
TYPE="text/css" 
HREF="wls_examples.css" 
TITLE="BEA WebLogic Server">


</head>

<body bgcolor="#ffffff" link="#3366cc" vlink="#9999cc" alink="#0000cc">

<!-- top intro paragraph tables -->
<!-- RED LINE -->
<table cellspacing="0" cellpadding="0"  border="0" width="100%">
    <tr>
     <td  width="100%" bgcolor="#ff0000" height="1">
     <p class="small">&nbsp;</p>
     </td>
     </tr>
</table>

<table border=0 cellspacing="18" cellpadding="0">
<tr>
<td valign="top">
<a HREF="http://www.bea.com"><IMG SRC="images/logo_tm_onwt.jpg" alt="BEA Logo" border="0"></a>

 <h3>Order Parser using XMLInputStream API</h3>
 
 </td>
 </tr>
</table>

<table cellspacing="0" cellpadding="0"  border="0" width="100%">
    <tr>
     <td  width="100%" bgcolor="#ff0000" height="1">
     <p class="small">&nbsp;</p>
     </td>
     </tr>
</table>

<table border=0 cellspacing="18" cellpadding="0">
<tr>
<td valign="top">

<%@ page import="
examples.xml.orderParser.*
" %>

<%
    String xmlFile = request.getParameter("xmlfile");
    String errorMsg = "XML file parameter missing or file does not exist.";
    
    try {
    if (xmlFile == null || !(new File(xmlFile)).exists()) {
%>
      <table border=0 cellpadding=1>
        <tr><td><%=errorMsg%></td></tr>        
      </table>
<%
      throw new FileNotFoundException(errorMsg);
    }
    else {
      StreamParser sp = new StreamParser();
      try {
        // Get inputsteam and pass for processing.
        sp.parse(sp.getInputStream(xmlFile));
        // Print resulting order business object.
        sp.getOrderBO().printOrder();
      } catch (Exception e) {
        e.printStackTrace();
      }
      
      OrderBO order = sp.getOrderBO();
      CustomerBO customer;  
      Vector vItems;
      if (order != null) {
        customer = order.getCustomer();
        vItems = order.getItems();
%>
        <table border=0 cellpadding=1>
          <tr><td><b>Order Number</b></td><td><%=order.getOrderNumber()%></td></tr>
          <tr><td><b>Customer Name</b></td><td><%=customer.getFirstName()%>&nbsp;&nbsp;<%=customer.getLastName()%></td></tr>
          <tr><td><b>Customer Address</b></td><td><%=customer.getStreet()%></td></tr>
          <tr><td>&nbsp;</td><td><%=customer.getCity()%>,&nbsp;<%=customer.getState()%>&nbsp;&nbsp;<%=customer.getZip()%></td></tr>
          <tr>&nbsp;</tr>        
        </table>
        
        <br/><br/>
        
        <table border=1 cellpadding=1>
          <th width="20%">Item Number</th>
          <th width="20%">Description</th>
          <th width="20%">Quantity</th>
          <th width="20%">Unit Cost ($)</th>
          <th width="20%">Total Cost ($)</th>
<%
        int numOrders = vItems.size();
        if (numOrders > 0) {
          for (int i=0; i < numOrders; i++) {
            ItemBO item = (ItemBO)vItems.elementAt(i);
            if (item != null) {
%>
              <tr><td><%=item.getItemNumber()%></td>
                <td><%=item.getDescription()%></td>
                <td><%=item.getQuantity()%></td>
                <td><%=item.getPrice()%></td>
                <td><%=item.getPrice()*item.getQuantity()%>
              </tr>
<%
            }
          }
        } else {
%>
          <tr>No items found</tr>
<%
        }
%>
        </table>
<%
      } else {
%>
      <p>
      No orders found.  Check your XML order file.
<%
      }
    }
  }catch (Exception e) {
    e.printStackTrace();
  }
%>
 </td>
 </tr>
</table>
<br>
<!-- RED LINE -->
<table cellspacing="0" cellpadding="0"  border="0" width="100%">
    <tr>
     <td  width="100%" bgcolor="#ff0000" height="1">
     <p class="small">&nbsp;</p>
     </td>
     </tr>
</table>

<!-- FOOTER -->
<table cellspacing="0" cellpadding="0" border="0" width="100%">
  <tr>
    <td align="left">
      <p class="copyright">Last updated: January 2003</p>
    </td>
  </tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="100%"><!-- RED LINE -->
   <tr> 
    <td  width="100%" bgcolor="#ff0000" height="1">
    <p class="small">&nbsp;</p>
    </td>
    </tr>
</table> 


 <p class="copyright"><a href="http://www.bea.com">Home</a> | 
        <a href="http://www.bea.com/about/index.shtml" target="_top">Corporate Info</a> | 
        <a href="http://www.bea.com/press/index.shtml" target="_top">News</a> | 
        <a href="http://www.bea.com/solutions/index.shtml" target="_top">Solutions</a> | 
        <a href="http://www.bea.com/products/index.shtml" target="_top">Products</a> | 
        <a href="http://www.bea.com/partners/index.shtml" target="_top">Partners</a> | 
        <a href="http://www.bea.com/services.shtml" target="_top">Services</a> | 
        <a href="http://www.bea.com/events/index.shtml" target="_top">Events</a> | 
        <a href="http://commerce.bea.com/downloads/products.jsp" target="_top">Download</a> | 
        <a href="http://www.bea.com/purchase.shtml" target="_top">How to Buy</a>
        <br>Copyright 2003, BEA Systems, Inc. All rights reserved.
        <br>Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.
        <br> <a href="http://www.bea.com/contact/index.shtml" target="_top">Contact BEA</a> 
      </p>

</body>
</html>

⌨️ 快捷键说明

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