JSPÖÐerrorPageµÄÎÊÌâ
µ±ÔÚJSPµÄpageÖ¸ÁîÖÐÉèÖÃerrorPage="url"¾Í¿ÉÒÔÉèÖô¦ÀíÒ쳣ʼþµÄJSPÎļþ¡£Èç¿ÉÒÔÕâÑùд£º
<%@ page errorPage="error.jsp" %>
ÕâÑùµÄ»°£¬µ±Ò³ÃæÖгöÏÖÒì³£µÄʱºò£¬¾Í»á×Ô¶¯Ìø×ªµ½´íÎó´¦ÀíÒ³Ãæ¡£µ«ÊÇҪעÒ⣬
Ö»Óе±Õý³£´ò¿ªÒ³Ã棬ȻºóÔÚÒ³ÃæÖгöÏÖÒì³£µÄʱºò²Å»áÌø×ªµ½´íÎó´¦ÀíÒ³Ãæ£¬Èç¹ûÒ³Ãæ±¾ÉíÓÐÓï·¨´íÎó¶ø³öÏÖÁ˱àÒë´íÎó£¬ÊDz»»áÌø×ªµÄ£¡
Àý£ºindex.jsp
<%@ page contentType="text/html; charset=GB2312" language="java" errorPage="error.jsp"%>
<html><head><title>lifecycle</title></head><body>
<%!
private int initVar = 0;
private int serviceVar = 0;
private int destroyVar = 0;
public void jspInit() { initVar ++; }
public void jspDestroy() { destroyVar ++; }
%>
<%
serviceVar ++;
String content1="³õʼ»¯´ÎÊý£º" + initVar;
String content2="ÏìÓ¦¿Í»§ÇëÇó´ÎÊý£º" + serviceVar;
String content3="Ïú»Ù´ÎÊý£º" + destroyVar;
out.println("<h1>hahaha</h1>");
if(serviceVar==5){
String info = getServletInfo();
throw new Exception("Exception in:" + info);
}
%>
<h1><%=content1%></h1><h1><%=content2%></h1><h1><%=content3%></h1>
<!--this is some funny words.-->
</body></html>
ÏÂÃæµÄÊÇerror.jsp
<%@ page contentType="text/html; charset=GB2312" language="java" isErrorPage="true"%>
<html><head><title>error</title></head><body>
this is the error page.
</body></html>
Ïà¹ØÎĵµ£º
ÔÚµ±Ç°Ó¦ÓÃϵͳµÄweb.xmlÀï¼ÓÈëjsp-config´úÂ룺
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<jsp-config>
< ......
1¡¢<%=(new java.util.Date()).toLocaleString()%>
2¡¢<script language= "javascript ">
var today=new Date()
var month=today.getMonth()+1
document.write(today.getYear()+ "Äê "+month+ "ÔÂ "+today.getDate()+ "ÈÕ ")
  ......
Ò»¡¢ÊµÑéÄ¿µÄ
1¡¢ ÕÆÎÕ±íµ¥µÄʹÓ÷½·¨£¬ÒÔ¼°·þÎñÆ÷¶Ë´¦Àí±íµ¥ÇëÇóµÄ·½·¨£»
2¡¢ Àí½âForwardµÄ×÷Óã»
3¡¢ ÊìÁ·ÔËÓÃJSPµÄµäÐÍÄÚÖöÔÏó
¶þ¡¢ÊµÑéÄÚÈݼ°²½Öè
1¡¢±íµ¥µÄʹÓü°ÆäµÝ½»¡¢´¦Àí¹ý³Ì
ÔÚÔ´´½ÌÎñϵͳÖУ¬ÏµÍ³»á¸ù¾ÝÓû§ÀàÐÍ(½Ìʦ/ѧÉú)ÏÔʾ²»Í¬µÄÒ³Ãæ¡£ÎªÄ£Äâ¸Ã¹¦ÄÜ£¬ÐèÒª¶¨ÒåÉè¼ÆÈçÏÂҳà ......
Ëѹ·Ë«ºËä¯ÀÀÆ÷³öÀ´Ö®ºó£¬ÎÒ¾ÍÓÃËüÀ´µ÷ÊÔÒ³Ãæ£¬°´Ò»¸ö°´Å¥¿ÉÒÔÇл»Á½ÖÖä¯ÀÀÆ÷ÒÔ¹Û²ìÍøÒ³Ð§¹û£¬»¹ÊDZȽϷ½±ãµÄ£¬µ«ÊÇ×î½ü·¢ÏÖËѹ·µÄJSP sessionÃ²ËÆ³öÏÖÎÊÌâ¡£»¹ÔÚ²âÊÔÖУ¬×î½üÒ»Á½Ìì»áд³öÒ»¸ö±È½ÏÏêϸµÄ²âÊÔ±¨¸æ¡£°¥£¬ÄѵÀÊÇÎÒµÄsessionдµÄÓÐÎÊÌ⣿ÔõôÔÚÍøÉÏËѲ»µ½ÀàËÆµÄ¶«Î÷... ......
tomcat ĬÈÏʹÓõÄ×Ö·û¼¯ÊÇISO-8859-1£¬²»Ö§³ÖÖÐÎÄ×Ö·û£¬ËùÒÔÔÚÏÖʵÖÐÎÄʱÐèҪת»»×Ö·ûºÍÉèÖÃ×Ö·û¼¯¡£
server.mxl¸ÄΪ<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> £¬Ìí¼Ó´úÂëת»»×Ö·ûString.getBytes("ISO-8859-1"),"UTF-8 ......