<html>
<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>JSP入门教程(2)</strong></big></p>
<div align="right">作者:SUN 汉化:JSPER 整理:JSPER</div>
<P align=center class=MsoNormal style="TEXT-ALIGN: center"><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">第二课:用</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt">HTML</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">表单</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt"><O:P> </O:P></SPAN></B></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">大多数情况下,商业的网站都要有一些表单,比如说输入一下消费者的姓名啦,地址啦,或者敲一个词来用搜索引擎来查一下啦,或者市场人员从来访者处收集一些数据供参考什么的。</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt"><O:P> </O:P></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">那些表单传回的数据怎么处理的?</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt"><O:P> </O:P></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">来访者通过表单向</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt">JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">引擎输入了数据,并保存在了</SPAN><SPAN
lang=EN-US style="mso-font-kerning: 0pt">request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">对象中,那么接下来怎么办?</SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</SPAN><SPAN
lang=EN-US>2-1</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">向你展示了数据流是如何在服务器和客户之间传递的(至少在</SPAN><SPAN
lang=EN-US>SUN</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN
lang=EN-US>JSP reference implementation</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是这么做的,别的</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎工作起来可能会有一点点的不同,其实大同小异,都差不多)</SPAN></P>
<P align=center class=MsoNormal
style="TEXT-ALIGN: center; TEXT-INDENT: 21.75pt"> <IMG height=246 src="images/01002.1.gif" width=333
v:shapes="_x0000_i1025"></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字儿太小了,可能看不大清吧?俺来解释一下了只好。</SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">首先,</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎把存放在</SPAN><SPAN
lang=EN-US>request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象中的数据发到</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">页面指定的服务器端的组件(</SPAN><SPAN
lang=EN-US>JavaBeans</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件</SPAN> , servlet,</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或者</SPAN><SPAN
lang=EN-US>enterprise bean</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">),组件收到这些个数据以后,有可能再存这些数据到数据库或者其他的地方存放起来,同时,返回一个</SPAN><SPAN
lang=EN-US>response</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象给</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎。</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎再把</SPAN><SPAN
lang=EN-US>response</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象传给</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">页面,这时的页面包含了定义好的格式和从服务器端得到的数据。这时</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎和</SPAN><SPAN
lang=EN-US>Web</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器再发送一个整理好的完整的页面给客户,也就是这们在浏览器上看到的结果。客户和服务器间的通信协议可以用</SPAN><SPAN
lang=EN-US>HTTP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,当然也可以用其他的。</SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN
lang=EN-US>Request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US>Response</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象在你制作的</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">原代码中