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

📄 jspx2.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>The Example JSP Document</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="JSPX.html" />    <link rel="Next" href="JSPX3.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="JSPX.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="JSPX3.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="wp116707"> </a><h2 class="pHeading1">The Example JSP Document</h2><a name="wp116737"> </a><p class="pBody">This chapter uses the <code class="cCode">bookstore5</code> and <code class="cCode">books</code> applications to demonstrate writing JSP pages in XML syntax. The JSP pages of the <code class="cCode">bookstore5</code> application use the JSTL XML tags (see <a  href="JSTL5.html#wp63716">XML Tags</a>) to manipulate the book data from an XML stream. The <code class="cCode">books</code> application contains the JSP document, <code class="cCode">books.jspx</code>, which accesses the book data from the database and converts it into the XML stream. The <code class="cCode">bookstore5</code> application accesses this XML stream to get the book data.</p><a name="wp118546"> </a><p class="pBody">These applications show how easy it is to generate XML data and stream it between Web applications. The <code class="cCode">books</code> application could be considered the application hosted by the book warehouse's server. The <code class="cCode">bookstore5</code> application could be considered the application hosted by the book retailer's server. In this way, the customer of the bookstore Web site sees the list of books currently available, according to the warehouse's database.</p><a name="wp116762"> </a><p class="pBody">The source for the Duke&#39;s Bookstore application is located in the <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/bookstore5/</code> directory created when you unzip the tutorial bundle (see <a  href="About.html#wp63740">About the Examples</a>). Sample <code class="cCode">bookstore5.war</code> and <code class="cCode">books.war</code> files are provided in <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/provided-wars/</code>. </p><a name="wp116862"> </a><p class="pBody">To build, package, deploy, and run the applications: </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp120267"> </a><div class="pSmartList1"><li>Build and package the <code class="cCode">bookstore</code> common files as described in <a  href="WebApp12.html#wp189559">Duke's Bookstore Examples</a>.</li></div><a name="wp116896"> </a><div class="pSmartList1"><li>In a terminal window, go to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/bookstore5/</code>.</li></div><a name="wp116897"> </a><div class="pSmartList1"><li>Run <code class="cCode">asant</code> <code class="cCode">build</code>. This target will spawn any necessary compilations and copy files to the <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/bookstore5/build/</code> directory. </li></div><a name="wp120804"> </a><div class="pSmartList1"><li>Start the J2EE 1.4 Application Server.</li></div><a name="wp120805"> </a><div class="pSmartList1"><li>Perform all the operations described in <a  href="WebApp13.html#wp69868">Accessing Databases from Web Applications</a>.</li></div><a name="wp120807"> </a><div class="pSmartList1"><li>Start <code class="cCode">deploytool</code>.</li></div><a name="wp117098"> </a><div class="pSmartList1"><li>Create a Web application called <code class="cCode">bookstore5</code> by running the New Web Application Wizard. Select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Web Component.</li></div><a name="wp117099"> </a><div class="pSmartList1"><li>New Web Component Wizard</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp117100"> </a><div class="pSmartList2"><li>In the Introduction screen click Next.</li></div><a name="wp121611"> </a><div class="pSmartList2"><li>In the WAR File screen, select the Create New Stand-Alone WAR Module radio button.</li></div><a name="wp117101"> </a><div class="pSmartList2"><li>Click Browse and in the file chooser, navigate to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/bookstore5/</code>. </li></div><a name="wp117102"> </a><div class="pSmartList2"><li>In the File Name field, enter <code class="cCode">bookstore5</code>.</li></div><a name="wp117103"> </a><div class="pSmartList2"><li>Click Choose Module File.</li></div><a name="wp117104"> </a><div class="pSmartList2"><li>In the WAR Name field, enter <code class="cCode">bookstore5</code>.</li></div><a name="wp117105"> </a><div class="pSmartList2"><li>In the Context Root field, enter <code class="cCode">/bookstore5</code>.</li></div><a name="wp117106"> </a><div class="pSmartList2"><li>Click Edit to add the content files. </li></div><a name="wp117107"> </a><div class="pSmartList2"><li>In the Edit Contents dialog, navigate to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/web/bookstore5/build</code>/. Select the JSP pages <code class="cCode">bookcashier.jsp</code>, <code class="cCode">bookcatalog.jsp</code>, <code class="cCode">bookdetails.jsp</code>, <code class="cCode">bookreceipt.jsp</code>, <code class="cCode">bookshowcart.jsp</code>, <code class="cCode">bookstore.jsp</code>, <code class="cCode">parseBooks.jsp </code>and the <code class="cCode">template</code> directory and click Add. Click OK.</li></div><a name="wp117108"> </a><div class="pSmartList2"><li>Add the shared bookstore library. Navigate to<code class="cCode"> &lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/build/web/bookstore/dist/</code>. Select <code class="cCode">bookstore.jar</code> and Click Add.</li></div><a name="wp117109"> </a><div class="pSmartList2"><li>Click OK.</li></div><a name="wp117110"> </a><div class="pSmartList2"><li>Click Next.</li></div><a name="wp117111"> </a><div class="pSmartList2"><li>Select the JSP radio button. </li></div><a name="wp117112"> </a><div class="pSmartList2"><li>Click Next.</li></div><a name="wp117113"> </a><div class="pSmartList2"><li>Select /<code class="cCode">bookstore.jsp</code> from the JSP Filename combo box. </li></div><a name="wp117114"> </a><div class="pSmartList2"><li>Click Finish.</li></div></ol></div><a name="wp117118"> </a><div class="pSmartList1"><li>Add each of the Web components listed in <a  href="JSPX2.html#wp117157">Table 13-1</a>. For each component:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp117119"> </a><div class="pSmartList2"><li>Select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Web Component.</li></div><a name="wp121612"> </a><div class="pSmartList2"><li>Click Next in the Introduction screen.</li></div><a name="wp117120"> </a><div class="pSmartList2"><li>In the WAR File screen, click the Add to Existing WAR Module radio button. Since the WAR file contains all of the JSP pages, you do not have to add any more content.</li></div><a name="wp117121"> </a><div class="pSmartList2"><li>Click Next.</li></div><a name="wp117122"> </a><div class="pSmartList2"><li>Select the JSP radio button. </li></div><a name="wp117123"> </a><div class="pSmartList2"><li>Click Next.</li></div><a name="wp117124"> </a><div class="pSmartList2"><li>Select the page from the JSP Filename combo box. </li></div><a name="wp117125"> </a><div class="pSmartList2"><li>Click Finish.</li></div><a name="wp117126"> </a><div class="pSmartList2"><li>Select the Web component you added from the tree.</li></div><a name="wp117441"> </a><div class="pSmartList2"><li>Select the Aliases tabbed pane.</li></div><a name="wp117442"> </a><div class="pSmartList2"><li>Click Add. Enter the alias as shown in <a  href="JSPX2.html#wp117157">Table 13-1</a>.<div align="left"><table border="1" summary="Duke's Bookstore Web Components" id="wp117157">  <caption><a name="wp117157"> </a><div class="pTableTitle">Table 13-1   Duke's Bookstore Web Components&nbsp;</div></caption>  <tr align="center">    <th><a name="wp117163"> </a><div class="pCellHeading">Web Component Name</div></th>    <th><a name="wp117165"> </a><div class="pCellHeading">JSP Page</div></th>    <th><a name="wp117167"> </a><div class="pCellHeading">Component Alias</div></th></tr>  <tr align="left">    <td><a name="wp121446"> </a><div class="pCellBody"><code class="cCode">bookcashier</code></div></td>    <td><a name="wp121448"> </a><div class="pCellBody"><code class="cCode">bookcashier.jsp</code></div></td>    <td><a name="wp121450"> </a><div class="pCellBody"><code class="cCode">/bookcashier</code></div></td></tr>  <tr align="left">    <td><a name="wp121452"> </a><div class="pCellBody"><code class="cCode">bookcatalog</code></div></td>    <td><a name="wp121454"> </a><div class="pCellBody"><code class="cCode">bookcatalog.jsp</code></div></td>    <td><a name="wp121456"> </a><div class="pCellBody"><code class="cCode">/bookcatalog</code></div></td></tr>  <tr align="left">    <td><a name="wp121458"> </a><div class="pCellBody"><code class="cCode">bookdetails</code></div></td>    <td><a name="wp121460"> </a><div class="pCellBody"><code class="cCode">bookdetails.jsp</code></div></td>    <td><a name="wp121462"> </a><div class="pCellBody"><code class="cCode">/bookdetails</code></div></td></tr>  <tr align="left">    <td><a name="wp121470"> </a><div class="pCellBody"><code class="cCode">bookreceipt</code></div></td>    <td><a name="wp121472"> </a><div class="pCellBody"><code class="cCode">bookreceipt.jsp</code></div></td>

⌨️ 快捷键说明

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