15-2 ����Y��T���B�z

·í¦øªA¾¹±Nºô­¶¸ê°T¦^¶Ç¦Ü¥Î¤áºÝ®É¡A³q±`·|¦bºô­¶¸ê®Æ¤§«e¡A¥ý¶Ç°e¤@¨ÇªíÀY¸ê°T¡A³o¨Ç¸ê°T¥i¥HÅý¥Î¤áºÝªºÂsÄý¾¹ª¾¹D¦p¦ó§e²{©Ò¦¬¨ìªº¸ê®Æ¡C

¤U­±³o­Ó½d¨Ò¡A¨Ï¥Î Response.Redirect ¨Ó¶i¦æÂà§}¡G

Example¡]response/redirect.asp¡^¡G

¦b¤W­z½d¨Ò¤¤¡A¥u­n¨Ï¥ÎªÌ¥ô¿ï¤@­Ó¿ï¶µ¡Aºô­¶§Y·|Âà§}¨ì¬ÛÃöªººô§}¡C¤W­z½d¨Òªº­ì©lÀɦp¤U¡G

­ì©lÀÉ¡]response/redirect.asp¡^¡G¡]¦Ç¦â°Ï°ì«ö¨â¤U§Y¥i«þ¨©¡^
<%@language=JScript%>
<%
x=Request.Form("url")+"";		// Âন¦r¦ê
if (x!="undefined")		// ¥Nªí¥ÑÂI¿ïªí³æ¨Ó­«·s¸ü¤J¦¹­¶¡A¥Ñ¦¹¶}©lÂà§}
	Response.Redirect(Request.Form("url"));
%>

<%title="Response.Redirect ªº½d¨Ò"%>
<!--#include file="../head.inc"-->
<hr>

½Ð¿ï¤@­ÓÂà§}¥Ø¼Ð¡G
<form method=post>
<input type=radio name=url value=http://www.ntu.edu.tw onClick="this.form.submit()">¥x¤j­º­¶<br>
<input type=radio name=url value=http://www.nthu.edu.tw onClick="this.form.submit()">²M¤j­º­¶<br>
<input type=radio name=url value=http://www.google.com onClick="this.form.submit()">Google ·j´M<br>
</form>

<hr>
<!--#include file="../foot.inc"-->

¯S§O­nª`·Nªº¬O¡GResponse.Redirect ©Ò¥]§tªº¸ê°T³£¬OÄÝ©óªíÀY¸ê°T¡A¦b Response.Buffer = false ªº±¡ªp¤U¡A³o¨ÇªíÀY¸ê°T¥²¶·¥X²{¦b¥ô¦óºô­¶¤º®e¤§«e¡A§_«h´N·|³y¦¨¿ù»~¡C¡]«áÄò·|¦³¸Ô²Ó»¡©ú¡C¡^

¤U­±³o­Ó½d¨Ò¡A¨Ï¥Î Response.Charset ¶Ç°eºô­¶¤å¥óªº½s½X¸ê°T¡G

Example¡]response/charset.asp¡^¡G

¤W­z½d¨Òªº­ì©lÀɦp¤U¡G

­ì©lÀÉ¡]response/charset.asp¡^¡G¡]¦Ç¦â°Ï°ì«ö¨â¤U§Y¥i«þ¨©¡^
<%@language=JScript%>
<% Response.Charset="x-sjis" %>
<%title="Response.Charset ªº½d¨Ò"%>
<!--#include file="../head.inc"-->
<hr>

<p>This page is encoded in "x-sjis", which is a Japanese character set.
<br>In order to view the following Big5 characters, you need to change the document encoding.
<br>§A­Y¬Ý±oÀ´³o¤@¥y¤¤¤å¡A¥Nªí§A¤w¸g±Nºô­¶½s½X§ï¦¨¡uÁcÅ餤¤å (Big 5)¡v¤F¡I

<hr>
<!--#include file="../foot.inc"-->

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì¸g¥Ñ Response.Charset="x-sjis" ±N¤å¥ó½s½X³]©w¦¨¤é¤å½s½X¡A©Ò¥H¬Ý¤£¨ì¤¤¤å¡C¡]¦pªG§Aªº¨t²Î¨S¦³¦w¸Ë¤é¤å¦r§Î¡AIE ¤]·|¸ß°Ý¬O§_­n¦w¸Ë¤é¤å¦r§Î¡C¡^¥u¦³¸g¥Ñ¤â°Ê±Nºô­¶½s½X§ï¦¨¡uÁcÅ餤¤å (Big 5)¡v¡A¤~¯à¬Ýªº¨ìºô­¶¤¤ªº¤¤¤å¡C

¨ä¹ê¡A¦b¤W­z½d¨Ò¤¤¡Aºô­¶©Ò¥]§tªºÀÉ®× head.inc ¤w¸g¦³¦b meta ¼ÐÅÒ¤ºµù©ú charset=big5¡A¥Ñ¦¹¥i¨£ IIS ¦øªA¾¹·|¥H ASP µ{¦¡½X¤ºªº Response.Charset ¬°¥D¡A¦Ó©¿²¤ meta ¼ÐÅÒ¤ºªº³]©w¡C

§Ú­Ì¤]¥i¥H¨Ï¥Î Response ª«¥óªº AddHeader ¤èªk¨Ó¥[¤Jªí³æ¸ê°T¡A¨Ò¦p¡A¦b¤U­Ó½d¨Ò¤¤¡A§Ú­Ì¦bªí³æ¸ê°T©w¸q¤T¬í«áÂà§}¡A¦]¦¹¤U¦C½d¨Ò·|¦b¤T¬í«áª½±µÂà§}¨ì²MµØ¤j¾Çªº­º­¶¡A¦p¤U¡G

Example¡]response/addHeader.asp¡^¡G

¤W­z½d¨Òªº­ì©lÀɦp¤U¡G

­ì©lÀÉ¡]response/addHeader.asp¡^¡G¡]¦Ç¦â°Ï°ì«ö¨â¤U§Y¥i«þ¨©¡^
<%@language=JScript%>
<%Response.AddHeader("Refresh", "3; URL=http://www.csie.ntu.edu.tw");%>
<%title="Response.AddHeader ªº½d¨Ò"%>
<!--#include file="../head.inc"-->
<hr>
¦¹ºô­¶¦b¤T¬í«á·|³s¨ì¥x¤j¸ê¤u¨t­º­¶¡I
<hr>
<!--#include file="../foot.inc"-->

¦b¤W­z½d¨Ò¤¤¡A¨Ï¥Î AddHeader ©Ò±o¨ìªº®ÄªG¡A¬O©M¤U¦C HTML ºô­¶¤¤ªº <meta> ¼ÐÅÒ©Ò±o¨ìªºÂà§}®ÄªG¬O¤@¼Ëªº¡G

<meta http-equiv="Refresh" content="3; URL=http://www.cs.nthu.edu.tw">

¤U­±³o­Ó½d¨Ò¦C¦L¥X Response ª«¥óªº¦U­Ó©Ê½èªº¹w³]­È¡G

Example¡]response/listResponse.asp¡^¡G

¤W­z½d¨Òªº­ì©lÀɦp¤U¡G

­ì©lÀÉ¡]response/listResponse.asp¡^¡G¡]¦Ç¦â°Ï°ì«ö¨â¤U§Y¥i«þ¨©¡^
<%@language=jscript%>
<%title="¦L¥X Response ª«¥óªº¦UºØ©Ê½è"%>
<!--#include file="../head.inc"-->
<hr>

Response.Buffer = <%=Response.Buffer%><br>
Response.ContentType = <%=Response.ContentType%><br>
Response.Expires = <%=Response.Expires%><br>
Response.ExpiresAbsolute = <%=Response.ExpiresAbsolute%><br>
Response.Status = <%=Response.Status%><br>

<hr>
<!--#include file="../foot.inc"-->

¨ä¤¤ Response.Status ¬ö¿ýºô­¶¦^¶Çªºª¬ºA¡A­Y¬O¡u200 OK¡v¡A¥Nªí¤@¤ÁµL»~¡C¨ä¥L¥i¯àªº°T®§¤Î¬ÛÃöªº»¡©ú¡A½Ð¨£¤U¦Cªí®æ¡G
ª¬ºA½X ­^¤å»¡©ú ¤¤¤å»¡©ú
2xx Success ºô­¶¶Ç°e§¹¦¨°e¹F¤§¤u§@¤§ª¬ªp
200 OK; the request was fulfilled. ºô­¶¶Ç°e§¹¦¨
201 OK; following a POST command. ºô­¶¶Ç°e§¹¦¨¡A¥Hpost command ®æ¦¡¶Ç°e
202 OK; accepted for processing, but processing is not completed. ºô­¶¶Ç°e¤w°e¹F¡A¦ýµ{§Ç¦³°ÝÃD¡AµLªk§¹¾ã°õ¦æµ{§Ç¡C
203 OK; partial information--the returned information is only partial. ºô­¶¶Ç°e¤w°e¹F¡A¦ý¦]¬Y¨Ç¦]¯À¥u¯à¦^¶Ç³¡¤À¸ê°T¡C
204 OK; no response--request received but no information exists to send back. ºô­¶¶Ç°e¤w°e¹F¡A¦ý¦]¬Y¨Ç¦]¯ÀµLªk¦^¶Ç¸ê°T¡C
3xx Redirection «ØÄ³Âà§}¡I
301 Moved--the data requested has a new location and the change is permanent. ±z©Ò­n¨Dªººô§}¤w¥Ã¤[¾E²¾¡C
302 Found--the data requested has a different URL temporarily. ±z©Ò­n¨Dªººô§}¼È®É¾E²¾¡C
303 Method--under discussion, a suggestion for the client to try another location. ±z©Ò­n¨Dªººô§}¥Ø«e¦³©Òª§Ä³¡A«ØÄ³±z¸Õ¸Õ§Oªº¦ì§} ¡C
304 Not Modified--the document has not been modified as expected. ­n¶Ç°e¸ê®Æ¤£¦X³W©w¡C
4xx Error seems to be in the client ¥Î¤áºÝºÃ¦³¿ù»~
400 Bad request--syntax problem in the request or it could not be satisfied. ¦b±zrequestªº »yªk¤¤¦³°ÝÃD¡A«ØÄ³±z­×¥¿¡A§_«h¥i¯àµLªk°õ¦æ¡C
401 Unauthorized--the client is not authorized to access data. ¥Î¤áºÝ¥¼¸g±ÂÅv¡AµLªk¶Ç±µ¸ê®Æ¡C
402 Payment required--indicates a charging scheme is in effect. ¥Ø«e°õ¦æ¦¹³B»Ý¥I¶O
403 Forbidden--access not required even with authorization. ¥Ø«e¦¹³B§¹¥þÃö³¬(§Y¨Ï³q¹L»{ÃÒ¥çµLªk³q¦æ)
404 Not found--server could not find the given resource. ¦øªA¾¹µLªk´MÀò¸ê·½
5xx Error seems to be in the server ¦øªA¾¹ºÝºÃ¦³¿ù»~
500 Internal Error--the server could not fulfill the request because of an unexpected condition. ¦]¤£¦W­ì¦]¡A¦øªA¾¹µLªk°õ¦æ¥Î¤áºÝ­n¨D
501 Not implemented--the sever does not support the facility requested. ¦øªA¾¹ºÝ¦b§Þ³N¤W¤£¤ä´©¥Î¤áºÝ­n¨D
502 Server overloaded--high load (or servicing) in progress. ¦øªA¾¹¦]¥I¸ü¹L­«¡A¥Ø«eµLªk°õ¦æ¡C
503 Gateway timeout--server waited for another service that did not complete in time. ¦øªA¾¹¦]³B²z¨ä¥Lprocess©Îµ¥«Ý®É¶¡¹L¤[¦Ó¶W¥X®É¶¡


JScript µ{¦¡³]­p»PÀ³¥Î¡G¥Î©ó¦øªA¾¹ºÝªº ASP Àô¹Ò