📄 webapp2.html
字号:
<?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>Web Application Life Cycle</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="WebApp.html" /> <link rel="Next" href="WebApp3.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="WebApp.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="WebApp3.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="wp64550"> </a><h2 class="pHeading1">Web Application Life Cycle</h2><a name="wp64551"> </a><p class="pBody">A Web application consists of Web components, static resource files such as images, and helper classes and libraries. The Web container provides many supporting services that enhance the capabilities of Web components and make them easier to develop. However, because it must take these services into account, the process for creating and running a Web application is different from that of traditional stand-alone Java classes.The process for creating, deploying, and executing a Web application can be summarized as follows:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp64562"> </a><div class="pSmartList1"><li>Develop the Web component code.</li></div><a name="wp88104"> </a><div class="pSmartList1"><li>Develop the Web application deployment descriptor.</li></div><a name="wp64563"> </a><div class="pSmartList1"><li>Compile the Web application components and helper classes referenced by the components.</li></div><a name="wp88109"> </a><div class="pSmartList1"><li>Optionally package the application into a deployable unit.</li></div><a name="wp64564"> </a><div class="pSmartList1"><li>Deploy the application into a Web container.</li></div><a name="wp64565"> </a><div class="pSmartList1"><li>Access a URL that references the Web application.</li></div></ol></div><a name="wp75485"> </a><p class="pBody">Developing Web component code is covered in the later chapters. Steps 2 through 4 are expanded on in the following sections and illustrated with a Hello, World style presentation-oriented application. This application allows a user to enter a name into an HTML form (<a href="WebApp2.html#wp64571">Figure 3-1</a>) and then displays a greeting after the name is submitted (<a href="WebApp2.html#wp64577">Figure 3-2</a>): </p><a name="wp64570"> </a><p class="pBody"></p><div align="left"><img src="images/Fig20.gif" height="243" width="407" alt="Greeting Form" border="0" hspace="0" vspace="0"/></div><p class="pBody"></p><p> <a name="64571"> </a><strong><font >Figure 3-1 Greeting Form</font></strong></p><a name="wp75503"> </a><p class="pBody"></p><div align="left"><img src="images/Fig212.gif" height="244" width="406" alt="Response" border="0" hspace="0" vspace="0"/></div><p class="pBody"></p><p> <a name="64577"> </a><strong><font >Figure 3-2 Response</font></strong></p><a name="wp64578"> </a><p class="pBody">The Hello application contains two Web components that generate the greeting and the response. This chapter discusses two versions of the application: a JSP version called <code class="cCode">hello1</code>, in which the components are implemented by two JSP pages, <code class="cCode"><a href="../examples/web/hello1/web/index.txt" target="_blank">index.jsp</a></code> and <code class="cCode"><a href="../examples/web/hello1/web/response.txt" target="_blank">response.jsp</a></code>, and a servlet version called <code class="cCode">hello2</code>, in which the components are implemented by two servlet classes, <code class="cCode"><a href="../examples/web/hello2/src/servlets/GreetingServlet.java" target="_blank">GreetingServlet.java</a></code> and <code class="cCode"><a href="../examples/web/hello2/src/servlets/ResponseServlet.java" target="_blank">ResponseServlet.java</a></code>. The two versions are used to illustrate tasks involved in packaging, deploying, configuring, and running an application that contains Web components. If you are viewing this tutorial online, you must download the tutorial bundle to get the source code for this example. See <a href="About.html#wp63740">About the Examples</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="WebApp.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="WebApp3.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 + -