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

📄 webapp11.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="wp85894"> </a><p class="pBody">For example, suppose you define a welcome file <code class="cCode">welcome.html</code>. When a client requests a URL such as <code class="cVariable">host:port/webapp/directory</code>, where <code class="cVariable">directory</code> is not mapped to a servlet or JSP page, the file <code class="cVariable">host:port/webapp/directory</code><code class="cCode">/welcome.html </code>is returned to the client. </p><a name="wp85895"> </a><p class="pBody">If a Web container receives a valid partial request, the Web container examines the welcome file list and appends each welcome file in the order specified to the partial request and checks whether a static resource or servlet in the WAR is mapped to that request URL. The Web container then sends the request to the first resource in the WAR that matches. </p><a name="wp88445"> </a><p class="pBody">If no welcome file is specified, the J2EE 1.4 Application Server will use a file named <code class="cCode">index.</code><code class="cVariable">XXX</code>, where <code class="cVariable">XXX</code> can be <code class="cCode">html</code> or <code class="cCode">jsp</code>, as the default welcome file. If there is no welcome file and no file named <code class="cCode">index.</code><code class="cVariable">XXX</code>, the application server returns a directory listing.</p><a name="wp215022"> </a><p class="pBody">To specify welcome files with <code class="cCode">deploytool</code>:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp215023"> </a><div class="pSmartList1"><li>Select the WAR.</li></div><a name="wp215024"> </a><div class="pSmartList1"><li>Select the File Refs tab in the WAR inspector. </li></div><a name="wp215025"> </a><div class="pSmartList1"><li>Click Add File in the Welcome Files pane.</li></div><a name="wp215026"> </a><div class="pSmartList1"><li>Select the welcome file from the drop-down list.</li></div></ol></div><a name="wp188453"> </a><p class="pBody">The example discussed in <a  href="JSPTags5.html#wp89664">Encapsulating Reusable Content using Tag Files</a> has a welcome file.</p><a name="wp99549"> </a><h3 class="pHeading2">Setting Initialization Parameters</h3><a name="wp215045"> </a><p class="pBody">The Web components in a Web module share an object that represents their application context (see <a  href="Servlets10.html#wp64724">Accessing the Web Context</a>). You can pass initialization parameters to the context or to a Web component. To add a Web component initialization parameter with <code class="cCode">deploytool</code>:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp215046"> </a><div class="pSmartList1"><li>Select the Web component.</li></div><a name="wp215047"> </a><div class="pSmartList1"><li>Select the Init. Parameters tab in the Web component inspector. </li></div><a name="wp215048"> </a><div class="pSmartList1"><li>Click Add.</li></div></ol></div><a name="wp215053"> </a><p class="pBody">To add a context parameter with <code class="cCode">deploytool</code>:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp215054"> </a><div class="pSmartList1"><li>Select the WAR.</li></div><a name="wp215055"> </a><div class="pSmartList1"><li>Select the Context tab in the WAR inspector. </li></div><a name="wp215056"> </a><div class="pSmartList1"><li>Click Add.</li></div></ol></div><a name="wp102465"> </a><p class="pBody">For an example context parameter, see the example discussed in <a  href="JSPIntro3.html#wp83415">The Example JSP Pages</a>.</p><a name="wp83548"> </a><h3 class="pHeading2">Specifying Error Mappings</h3><a name="wp215078"> </a><p class="pBody">You can specify a mapping between the status code returned in an HTTP response or a Java programming language exception returned by any Web component and a Web resource (see <a  href="Servlets4.html#wp76701">Handling Errors</a>). To set up the mapping with <code class="cCode">deploytool</code>:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp215079"> </a><div class="pSmartList1"><li>Select the WAR.</li></div><a name="wp215080"> </a><div class="pSmartList1"><li>Select the File Refs tab in the WAR inspector. </li></div><a name="wp215081"> </a><div class="pSmartList1"><li>Click Add Error in the Error Mapping pane.</li></div><a name="wp215085"> </a><div class="pSmartList1"><li>Enter the HTTP status code (see <a  href="HTTP3.html#wp63687">HTTP Responses</a>) or fully-qualified class name of an exception in the Error/Exception field.</li></div><a name="wp215086"> </a><div class="pSmartList1"><li>Enter the name of a resource to be invoked when the status code or exception is returned. The name should have a leading forward slash <code class="cCode">/</code>.</li></div></ol></div><hr><a name="wp84126"> </a><p class="pNote">Note: You can also define error pages for a JSP page contained in a WAR. If error pages are defined for both the WAR and a JSP page, the JSP page's error page takes precedence. See <a  href="JSPIntro4.html#wp65997">Handling Errors&nbsp;</a>.</p><hr><a name="wp81804"> </a><p class="pBody">For an example error page mapping, see the example discussed in <a  href="Servlets3.html#wp63984">The Example Servlets</a>.</p><a name="wp83876"> </a><h3 class="pHeading2">Declaring References to Environment Entries, Resource Environment Entries, or Resources</h3><a name="wp215121"> </a><p class="pBody">If your Web components reference environment entries, resource environment entries, or resources such as databases, you must declare the references in the Web application deployment descriptor. To add a reference to a resource with <code class="cCode">deploytool</code>:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp215122"> </a><div class="pSmartList1"><li>Select the WAR.</li></div><a name="wp215123"> </a><div class="pSmartList1"><li>Select the Environment, Enterprise Bean Refs, Resource Env. Refs, or Resource Refs tab in the WAR inspector. </li></div><a name="wp215124"> </a><div class="pSmartList1"><li>Click Add to add a new reference.</li></div><a name="wp215125"> </a><div class="pSmartList1"><li>Type a JNDI name for the resource.</li></div><a name="wp215126"> </a><div class="pSmartList1"><li>Choose the type of the resource.</li></div><a name="wp215127"> </a><div class="pSmartList1"><li>Choose whether the container or the application performs authentication when the resource is accessed.</li></div><a name="wp215128"> </a><div class="pSmartList1"><li>Choose whether the resource can be shared by more than one Web application.</li></div></ol></div><a name="wp81797"> </a><p class="pBody">For an example resource reference, see <a  href="WebApp13.html#wp85541">Configuring the Web Application to Reference a Resource</a>.</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="WebApp10.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="WebApp12.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 + -