webʵÑ鱨¸æ——±íµ¥ÓëJSPÄÚÖöÔÏó
Ò»¡¢ÊµÑéÄ¿µÄ
1¡¢ ÕÆÎÕ±íµ¥µÄʹÓ÷½·¨£¬ÒÔ¼°·þÎñÆ÷¶Ë´¦Àí±íµ¥ÇëÇóµÄ·½·¨£»
2¡¢ Àí½âForwardµÄ×÷Óã»
3¡¢ ÊìÁ·ÔËÓÃJSPµÄµäÐÍÄÚÖöÔÏó
¶þ¡¢ÊµÑéÄÚÈݼ°²½Öè
1¡¢±íµ¥µÄʹÓü°ÆäµÝ½»¡¢´¦Àí¹ý³Ì
ÔÚÔ´´½ÌÎñϵͳÖУ¬ÏµÍ³»á¸ù¾ÝÓû§ÀàÐÍ(½Ìʦ/ѧÉú)ÏÔʾ²»Í¬µÄÒ³Ã档ΪģÄâ¸Ã¹¦ÄÜ£¬ÐèÒª¶¨ÒåÉè¼ÆÈçÏÂÒ³Ã棺
-Login.html£º°üÀ¨Óû§ÀàÐÍÃû£¨Ä¬ÈÏΪѧÉúÀàÐÍ£©¡¢Óû§Ãû¡¢Óû§ÃÜÂë
Ô´´úÂ룺
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=gbk">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form name="Login" action="Forward.jsp" method="post">
<table>
<tr>
<td>Óû§ÀàÐÍ</td>
<td>
<select name ="User">
<option value="Student">ѧÉú</option>
<option value="Teacher">ÀÏʦ</option>
</select>
</td>
</tr>
<tr>
<td>̞</td>
<td>
<input name="Username" type="text" size="20">
</td>
</tr>
<tr>
<td>Óû§ÃÜÂë</td>
&nb
Ïà¹ØÎĵµ£º
ÔÚ¸÷ÖÖÍøÒ³ÖÆ×÷¼¼ÊõÂÛ̳ÖУ¬³£³£ÓÐÈËѯÎÊjavascriptÓëJavaÓÐʲôÇø±ð£¬ÉõÖÁÓÐÈËÎóÈÏΪjavascript¾ÍÊÇJava¡£javascriptÓëJavaȷʵÓÐÒ»¶¨µÄÁªÏµ£¬µ«ËüÃDz¢²»ÏñÎÒÃÇÏëÏóµÄÄÇÑùÁªÏµ½ôÃÜ£¬ÉõÖÁ¿ÉÒԿ϶¨µØ˵ËüÃÇÓкܴóµÄÇø±ð¡£
¡¡¡¡Ê²Ã´ÊÇJavaScript £¿
¡¡¡¡JavaScript ÊÇ¶Ô ECMA 262 Ó ......
ÔÚJSPÖй²ÏíÊý¾Ý£¬´óÌå·ÖΪ2ÖÐÇé¿ö¡£Ò»ÊÇÔÚͬһ¸öÓû§µÄ²»Í¬Ò³ÃæÖ®¼ä¹²ÏíÊý¾Ý£¬¶þÊÇÔÚ²»Í¬µÄÓû§Ö®¼ä¹²ÏíÊý¾Ý.
¶ÔÓÚͬһ¸öÓû§µÄ»á»°£¬ÒªÏëÔÚ²»Í¬µÄÒ³ÃæÖ®¼ä¹²ÏíÊý¾Ý£¬¿ÉÓÐÒÔϼ¸ÖÖÑ¡Ôñ
¡ñ°ÑÊý¾Ý±£´æÔÚSessionÖУ¨ÕâÊǷdz£³£¼ûµÄ·½Ê½£©¡£
¡ñͨ¹ýCookie.
¡ñͨ¹ýÒþº¬µÄ±íµ¥°ÑÊý¾Ý´«µ½ÏÂÒ»¸öÒ³Ãæ¡£
¡ñͨ¹ýServletContext¶ ......
1.²¿ÊðÈýÖÖ·½Ê½£º
(1) ÔÚserver.xmlµÄHost±êÇ©ÄÚн¨Ò»¸öContext±êÇ©
<Context path="/learn1" reloadable="true" docBase="E:\work\tech\project\learn1\WebRoot" workDir="E:\work\tech\project\learn1\WebRoot\work" />
* workDirÊÇÖ¸To ......
ÔÚ¹ÜÀí¹¤¾ßÀïÃæÓÐÊý¾ÝÔ´ Ñ¡ÔñsqlÊý¾ÝÔ´
ÔÚ´úÂëÖУº
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content= ......
ת×Ô£ºhttp://blog.sina.com.cn/s/blog_5990faac0100dnfx.html
Cookie
£º·þÎñÆ÷ÔÚÒ»¸öÓ¦´ðÊײ¿´«µÝ¸øä¯ÀÀÆ÷µÄÃû³Æ
/
Öµ¶Ô¡£ä¯ÀÀÆ÷±£´æµÄʱ¼äÓÉ
cookie
µÄ¹ýÆÚʱ¼äÊôÐÔÀ´Ö¸¶¨¡£µ±ä¯ÀÀÆ÷Ïòij¸ö·þÎñÆ÷
·¢ËÍÒ»¸öÇëÇóʱ£¬Ëü»á¼ì²éÆä±£´æµÄ
cookie
£¬²¢ÔÚÇëÇóÊײ¿Öаüº¬´Óͬһ̨·þÎñÆ÷ÉϽÓÊÕµ½µÄËùÓÐ
cookie
¡£
Se ......