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

📄 servlets3.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</div></th></tr>  <tr align="left">    <td><a name="wp81277"> </a><div class="pCellBody">BannerServlet</div></td>    <td><a name="wp81279"> </a><div class="pCellBody">BannerServlet</div></td>    <td><a name="wp81281"> </a><div class="pCellBody">/banner</div></td></tr>  <tr align="left">    <td><a name="wp81283"> </a><div class="pCellBody"><code class="cCode">BookStoreServlet</code></div></td>    <td><a name="wp81285"> </a><div class="pCellBody"><code class="cCode">BookStoreServlet</code></div></td>    <td><a name="wp81287"> </a><div class="pCellBody"><code class="cCode">/bookstore</code></div></td></tr>  <tr align="left">    <td><a name="wp81289"> </a><div class="pCellBody"><code class="cCode">CatalogServlet</code></div></td>    <td><a name="wp81291"> </a><div class="pCellBody"><code class="cCode">CatalogServlet</code></div></td>    <td><a name="wp81293"> </a><div class="pCellBody"><code class="cCode">/bookcatalog</code></div></td></tr>  <tr align="left">    <td><a name="wp81295"> </a><div class="pCellBody"><code class="cCode">BookDetailsServlet</code></div></td>    <td><a name="wp81297"> </a><div class="pCellBody"><code class="cCode">BookDetailsServlet</code></div></td>    <td><a name="wp81299"> </a><div class="pCellBody"><code class="cCode">/bookdetails</code></div></td></tr>  <tr align="left">    <td><a name="wp81301"> </a><div class="pCellBody"><code class="cCode">ShowCartServlet</code></div></td>    <td><a name="wp81303"> </a><div class="pCellBody"><code class="cCode">ShowCartServlet</code></div></td>    <td><a name="wp81305"> </a><div class="pCellBody"><code class="cCode">/bookshowcart</code></div></td></tr>  <tr align="left">    <td><a name="wp81307"> </a><div class="pCellBody"><code class="cCode">CashierServlet</code></div></td>    <td><a name="wp81309"> </a><div class="pCellBody"><code class="cCode">CashierServlet</code></div></td>    <td><a name="wp81311"> </a><div class="pCellBody"><code class="cCode">/bookcashier</code></div></td></tr>  <tr align="left">    <td><a name="wp81313"> </a><div class="pCellBody"><code class="cCode">ReceiptServlet</code></div></td>    <td><a name="wp81315"> </a><div class="pCellBody"><code class="cCode">ReceiptServlet</code></div></td>    <td><a name="wp81317"> </a><div class="pCellBody"><code class="cCode">/bookreceipt</code></div></td></tr></table></div></li></div></ol></div><a name="wp81319"> </a><div class="pSmartList1"><li>Set the alias for each Web component.</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81320"> </a><div class="pSmartList2"><li>Select the component.</li></div><a name="wp81321"> </a><div class="pSmartList2"><li>Select the Aliases tab.</li></div><a name="wp81322"> </a><div class="pSmartList2"><li>Click the Add button.</li></div><a name="wp81323"> </a><div class="pSmartList2"><li>Enter the alias.</li></div></ol></div><a name="wp81327"> </a><div class="pSmartList1"><li>Add the listener class <code class="cCode">listeners.ContextListener</code> (described in <a  href="Servlets4.html#wp64218">Handling Servlet Life Cycle Events</a>).</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81329"> </a><div class="pSmartList2"><li>Select the Event Listeners tab.</li></div><a name="wp81330"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81331"> </a><div class="pSmartList2"><li>Select the <code class="cCode">listeners.ContextListener</code> class from drop down field in the Event Listener Classes panel.</li></div></ol></div><a name="wp81336"> </a><div class="pSmartList1"><li>Add an error page (described in <a  href="Servlets4.html#wp76701">Handling Errors</a>).</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81337"> </a><div class="pSmartList2"><li>Select the File Refs tab. </li></div><a name="wp81338"> </a><div class="pSmartList2"><li>Click Add in the Error Mapping panel.</li></div><a name="wp81339"> </a><div class="pSmartList2"><li>Enter <code class="cCode">exception.BookNotFoundException</code> in the Error/Exception field.</li></div><a name="wp81340"> </a><div class="pSmartList2"><li>Enter <code class="cCode">/errorpage.html</code> in the Resource to be Called field.</li></div><a name="wp81341"> </a><div class="pSmartList2"><li>Repeat for <code class="cCode">exception.BooksNotFoundException</code> and <code class="cCode">javax.servlet.UnavailableException</code>.</li></div></ol></div><a name="wp81343"> </a><div class="pSmartList1"><li>Add the filters <code class="cCode">filters.HitCounterFilter</code> and <code class="cCode">filters.OrderFilter</code> (described in <a  href="Servlets8.html#wp64572">Filtering Requests and Responses</a>).</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81347"> </a><div class="pSmartList2"><li>Select the Filter Mapping tab. </li></div><a name="wp81348"> </a><div class="pSmartList2"><li>Click Edit Filter List.</li></div><a name="wp81349"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81350"> </a><div class="pSmartList2"><li>Select <code class="cCode">filters.HitCounterFilter</code> from the Filter Class column. The deploytool will automatically enter <code class="cCode">HitCounterFilter</code> in the Display Name column.</li></div><a name="wp81351"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81352"> </a><div class="pSmartList2"><li>Select <code class="cCode">filters.OrderFilter</code> from the Filter Class column. The deploytool will automatically enter <code class="cCode">OrderFilter</code> in the Display Name column.</li></div><a name="wp81353"> </a><div class="pSmartList2"><li>Click OK.</li></div><a name="wp81354"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81355"> </a><div class="pSmartList2"><li>Select <code class="cCode">HitCounterFilter</code> from the Filter Name column.</li></div><a name="wp81356"> </a><div class="pSmartList2"><li>Select Servlet from the Target Type column. </li></div><a name="wp81357"> </a><div class="pSmartList2"><li>Select <code class="cCode">BookStoreServlet</code> from the Target column.</li></div><a name="wp81358"> </a><div class="pSmartList2"><li>Repeat for <code class="cCode">OrderFilter</code>. The target type is Servlet and the target is <code class="cCode">ReceiptServlet</code>.</li></div></ol></div><a name="wp81359"> </a><div class="pSmartList1"><li>Add a resource reference for the database.</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81360"> </a><div class="pSmartList2"><li>Select the Resource Refs tab.</li></div><a name="wp81361"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81362"> </a><div class="pSmartList2"><li>Enter <code class="cCode">jdbc/BookDB</code> in the Coded Name field.</li></div><a name="wp81363"> </a><div class="pSmartList2"><li>Accept the default type <code class="cCode">javax.sql.DataSource</code>.</li></div><a name="wp81364"> </a><div class="pSmartList2"><li>Accept the default authorization <code class="cCode">Container</code>.</li></div><a name="wp81365"> </a><div class="pSmartList2"><li>Accept the default selected <code class="cCode">Shareable</code>.</li></div><a name="wp81366"> </a><div class="pSmartList2"><li>Enter <code class="cCode">jdbc/BookDB</code> in the JNDI name field of the Sun-specific Settings frame.</li></div></ol></div><a name="wp81367"> </a><div class="pSmartList1"><li>Select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Save.</li></div><a name="wp81368"> </a><div class="pSmartList1"><li>Deploy the application. </li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81369"> </a><div class="pSmartList2"><li>Select Tools<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Deploy. </li></div><a name="wp81370"> </a><div class="pSmartList2"><li>In the Connection Settings frame, enter the user name and password you specified when you installed the J2EE 1.4 Application Server.</li></div><a name="wp81371"> </a><div class="pSmartList2"><li>Click OK.</li></div></ol></div><a name="wp76060"> </a><div class="pSmartList1"><li>To run the application, open the bookstore URL <code class="cCode">http://localhost:8080/bookstore1/bookstore</code>.</li></div></ol></div><a name="wp71209"> </a><h3 class="pHeading2">Troubleshooting</h3><a name="wp64187"> </a><p class="pBody">The Duke's Bookstore database access object returns the following exceptions:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp64190"> </a><div class="pSmartList1"><li><code class="cCode">BookNotFoundException</code>--Returned if a book can't be located in the bookstore database. This will occur if you haven't loaded the bookstore database with data by running <code class="cCode">asant</code> <code class="cCode">create-db_common</code> or if the database server hasn't been started or it has crashed.</li></div><a name="wp64191"> </a><div class="pSmartList1"><li><code class="cCode">BooksNotFoundException</code>--Returned if the bookstore data can't be retrieved. This will occur if you haven't loaded the bookstore database with data or if the database server hasn't been started or it has crashed.</li></div><a name="wp71525"> </a><div class="pSmartList1"><li><code class="cCode">UnavailableException</code>--Returned if a servlet can't retrieve the Web context attribute representing the bookstore. This will occur if the database server hasn't been started.</li></div></ul></div><a name="wp73577"> </a><p class="pBody">Because we have specified an error page, you will see the message <code class="cCode">The application is unavailable. Please try later</code>. If you don't specify an error page, the Web container generates a default page containing the message <code class="cCode">A Servlet Exception Has Occurred </code>and a stack trace that can help diagnose the cause of the exception. If you use <code class="cCode">errorpage.html</code>, you will have to look in the server log to determine the cause of the exception. </p>    </blockquote>   <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <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="Servlets2.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="Servlets4.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"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font>  </body></html>

⌨️ 快捷键说明

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