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

📄 cb5.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Coffee Break Server</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="CB4.html" />    <link rel="Next" href="CB6.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="CB4.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="CB6.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp70100"> </a><h2 class="pHeading1">Coffee Break Server</h2><a name="wp65934"> </a><p class="pBody">The Coffee Break Server uses servlets, JSP pages, and JavaBeans components to dynamically construct HTML pages for consumption by a Web browser client. The JSP pages use the template tag library discussed in <a  href="JSPTags7.html#wp90689">A Template Tag Library</a> to achieve a common look and feel among the HTML pages, and many of the JSTL custom tags discussed in Chapter&nbsp;<a  href="JSTL.html#wp74644"></a>. </p><a name="wp65941"> </a><p class="pBody">The Coffee Break Server implementation is organized along the Model-View-Controller design pattern. The <code class="cCode">Dispatcher</code> servlet is the controller. It examines the request URL, creates and initializes model JavaBeans components, and dispatches requests to view JSP pages. The JavaBeans components contain the business logic for the application--they call the Web services and perform computations on the data returned from the services. The JSP pages format the data stored in the JavaBeans components. The mapping between JavaBeans components and pages is summarized in <a  href="CB5.html#wp65951">Table 31-1</a>.</p><div align="left"><table border="1" id="wp65951">  <caption><a name="wp65951"> </a><div class="pTableTitle">Table 31-1   Model and View Components&nbsp;</div></caption>  <tr align="center">    <th><a name="wp65957"> </a><div class="pCellHeading">Function</div></th>    <th><a name="wp65959"> </a><div class="pCellHeading">JSP Page</div></th>    <th><a name="wp65961"> </a><div class="pCellHeading">JavaBeans Component</div></th></tr>  <tr align="left">    <td><a name="wp65963"> </a><div class="pCellBody">Update order data</div></td>    <td><a name="wp65965"> </a><div class="pCellBody"><code class="cCode">orderForm</code></div></td>    <td><a name="wp65967"> </a><div class="pCellBody"><code class="cCode">ShoppingCart</code></div></td></tr>  <tr align="left">    <td><a name="wp65969"> </a><div class="pCellBody">Update delivery and billing data</div></td>    <td><a name="wp65971"> </a><div class="pCellBody"><code class="cCode">checkoutForm</code></div></td>    <td><a name="wp65973"> </a><div class="pCellBody"><code class="cCode">CheckoutFormBean</code></div></td></tr>  <tr align="left">    <td><a name="wp65975"> </a><div class="pCellBody">Display order confirmation</div></td>    <td><a name="wp65977"> </a><div class="pCellBody"><code class="cCode">checkoutAck</code></div></td>    <td><a name="wp65979"> </a><div class="pCellBody"><code class="cCode">OrderConfirmations</code></div></td></tr></table></div><p class="pBody"></p><a name="wp65982"> </a><h3 class="pHeading2">JSP Pages</h3><a name="wp65983"> </a><h4 class="pHeading3">orderForm</h4><a name="wp65984"> </a><p class="pBody"><code class="cCode"><a  href="../examples/cb/server/web/orderForm.txt" target="_blank">orderForm</a></code> displays the current contents of the shopping cart. The first time the page is requested, the quantities of all the coffees are 0. Each time the customer changes the coffee amounts and clicks the Update button, the request is posted back to <code class="cCode">orderForm</code>. The <code class="cCode">Dispatcher</code> servlet updates the values in the shopping cart, which are then redisplayed by <code class="cCode">orderForm</code>. When the order is complete, the customer proceeds to the <code class="cCode">checkoutForm</code> page by clicking the Checkout link.</p><a name="wp65985"> </a><h4 class="pHeading3">checkoutForm</h4><a name="wp65986"> </a><p class="pBody"><code class="cCode"><a  href="../examples/cb/server/web/checkoutForm.txt" target="_blank">checkoutForm</a></code> is used to collect delivery and billing information for the customer. When the Submit button is clicked, the request is posted to the <code class="cCode">checkoutAck</code> page. However, the request is first handled by the <code class="cCode">Dispatcher</code>, which invokes the <code class="cCode">validate</code> method of <code class="cCode">checkoutFormBean</code>. If the validation does not succeed, the requested page is reset to <code class="cCode">checkoutForm</code>, with error notifications in each invalid field. If the validation succeeds, <code class="cCode">checkoutFormBean</code> submits suborders to each distributor and stores the result in the request-scoped <code class="cCode">OrderConfirmations</code> JavaBeans component and control is passed to <code class="cCode">checkoutAck</code>.</p><a name="wp65987"> </a><h4 class="pHeading3">checkoutAck</h4><a name="wp65988"> </a><p class="pBody"><code class="cCode"><a  href="../examples/cb/server/web/checkoutAck.txt" target="_blank">checkoutAck</a></code> simply displays the contents of the <code class="cCode">OrderConfirmations</code> JavaBeans component, which is a list of the suborders comprising an order and the ship dates of each suborder.</p><a name="wp65989"> </a><h3 class="pHeading2">

⌨️ 快捷键说明

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