\u4f7f\u7528System.out.println()<\/strong><\/div>\nSystem.out.println()\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u6807\u8bb0\u4e00\u6bb5\u4ee3\u7801\u662f\u5426\u88ab\u6267\u884c\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6253\u5370\u51fa\u5404\u79cd\u5404\u6837\u7684\u503c\u3002\u6b64\u5916\uff1a<\/p>\n
1.\u81ea\u4eceSystem\u5bf9\u8c61\u6210\u4e3aJava\u6838\u5fc3\u5bf9\u8c61\u540e\uff0c\u5b83\u4fbf\u53ef\u4ee5\u4f7f\u7528\u5728\u4efb\u4f55\u5730\u65b9\u800c\u4e0d\u7528\u5f15\u5165\u989d\u5916\u7684\u7c7b\u3002\u4f7f\u7528\u8303\u56f4\u5305\u62ecServlets\uff0cJSP\uff0cRMI\uff0cEJB's\uff0cBeans\uff0c\u7c7b\u548c\u72ec\u7acb\u5e94\u7528\u3002<\/p>\n
2.\u4e0e\u5728\u65ad\u70b9\u5904\u505c\u6b62\u8fd0\u884c\u76f8\u6bd4\uff0c\u7528System.out\u8fdb\u884c\u8f93\u51fa\u4e0d\u4f1a\u5bf9\u5e94\u7528\u7a0b\u5e8f\u7684\u8fd0\u884c\u6d41\u7a0b\u9020\u6210\u91cd\u5927\u7684\u5f71\u54cd\uff0c\u8fd9\u4e2a\u7279\u70b9\u5728\u5b9a\u65f6\u673a\u5236\u975e\u5e38\u91cd\u8981\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5c31\u663e\u5f97\u975e\u5e38\u6709\u7528\u4e86\u3002<\/p>\n
\u63a5\u4e0b\u6765\u7ed9\u51fa\u4e86\u4f7f\u7528System.out.println()\u7684\u8bed\u6cd5\uff1a<\/p>\n
System.out.println(\"Debugging message\");<\/pre>\n\u8fd9\u662f\u4e00\u4e2a\u4f7f\u7528System.out.print()\u7684\u7b80\u5355\u4f8b\u5b50\uff1a<\/p>\n
<%@taglib prefix=\"c\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" %>\r\n<html>\r\n<head><title>System.out.println<\/title><\/head>\r\n<body>\r\n<c:forEach var=\"counter\" begin=\"1\" end=\"10\" step=\"1\" >\r\n <c:out value=\"${counter-5}\"\/><\/br>\r\n <% System.out.println( \"counter= \" + \r\n pageContext.findAttribute(\"counter\") ); %>\r\n<\/c:forEach>\r\n<\/body>\r\n<\/html><\/pre>\n\u73b0\u5728\uff0c\u5982\u679c\u8fd0\u884c\u4e0a\u9762\u7684\u4f8b\u5b50\u7684\u8bdd\uff0c\u5b83\u5c06\u4f1a\u4ea7\u751f\u5982\u4e0b\u7684\u7ed3\u679c\uff1a<\/p>\n
-4\r\n-3\r\n-2\r\n-1\r\n0\r\n1\r\n2\r\n3\r\n4\r\n5<\/pre>\n\u5982\u679c\u4f7f\u7528\u7684\u662fTomcat\u670d\u52a1\u5668\uff0c\u60a8\u5c31\u80fd\u591f\u5728logs\u76ee\u5f55\u4e0b\u7684stdout.log\u6587\u4ef6\u4e2d\u53d1\u73b0\u591a\u51fa\u4e86\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n
counter=1\r\ncounter=2\r\ncounter=3\r\ncounter=4\r\ncounter=5\r\ncounter=6\r\ncounter=7\r\ncounter=8\r\ncounter=9\r\ncounter=10<\/pre>\n\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c06\u53d8\u91cf\u548c\u5176\u5b83\u7684\u4fe1\u606f\u8f93\u51fa\u81f3\u7cfb\u7edf\u65e5\u5fd7\u4e2d\uff0c\u7528\u6765\u5206\u6790\u5e76\u627e\u51fa\u9020\u6210\u95ee\u9898\u7684\u6df1\u5c42\u6b21\u539f\u56e0\u3002<\/p>\n
\u4f7f\u7528JDB Logger<\/strong><\/div>\nJ2SE\u65e5\u5fd7\u6846\u67b6\u53ef\u4e3a\u4efb\u4f55\u8fd0\u884c\u5728JVM\u4e2d\u7684\u7c7b\u63d0\u4f9b\u65e5\u5fd7\u8bb0\u5f55\u670d\u52a1\u3002\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u6846\u67b6\u6765\u8bb0\u5f55\u4efb\u4f55\u4fe1\u606f\u3002<\/p>\n
\u8ba9\u6211\u4eec\u6765\u91cd\u5199\u4ee5\u4e0a\u4ee3\u7801\uff0c\u4f7f\u7528JDK\u4e2d\u7684 logger API\uff1a<\/p>\n
<%@taglib prefix=\"c\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" %>\r\n<%@page import=\"java.util.logging.Logger\" %>\r\n\r\n<html>\r\n<head><title>Logger.info<\/title><\/head>\r\n<body>\r\n<% Logger logger=Logger.getLogger(this.getClass().getName());%>\r\n\r\n<c:forEach var=\"counter\" begin=\"1\" end=\"10\" step=\"1\" >\r\n <c:set var=\"myCount\" value=\"${counter-5}\" \/>\r\n <c:out value=\"${myCount}\"\/><\/br>\r\n <% String message = \"counter=\"\r\n + pageContext.findAttribute(\"counter\")\r\n + \" myCount=\"\r\n + pageContext.findAttribute(\"myCount\");\r\n logger.info( message );\r\n %>\r\n<\/c:forEach>\r\n<\/body>\r\n<\/html><\/pre>\n\u5b83\u7684\u8fd0\u884c\u7ed3\u679c\u4e0e\u5148\u524d\u7684\u7c7b\u4f3c\uff0c\u4f46\u662f\uff0c\u5b83\u53ef\u4ee5\u83b7\u5f97\u989d\u5916\u7684\u4fe1\u606f\u8f93\u51fa\u81f3stdout.log\u6587\u4ef6\u4e2d\u3002\u5728\u8fd9\u6211\u4eec\u4f7f\u7528\u4e86logger\u4e2d\u7684info\u65b9\u6cd5\u3002\u4e0b\u9762\u6211\u4eec\u7ed9\u51fastdout.log\u6587\u4ef6\u4e2d\u7684\u4e00\u4e2a\u5feb\u7167\uff1a<\/p>\n
24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=1 myCount=-4\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=2 myCount=-3\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=3 myCount=-2\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=4 myCount=-1\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=5 myCount=0\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=6 myCount=1\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=7 myCount=2\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=8 myCount=3\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=9 myCount=4\r\n24-Sep-2013 23:31:31 org.apache.jsp.main_jsp _jspService\r\nINFO: counter=10 myCount=5<\/pre>\n\u6d88\u606f\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u4f18\u5148\u7ea7\u53d1\u9001\uff0c\u901a\u8fc7\u4f7f\u7528sever()\uff0cwarning()\uff0cinfo()\uff0cconfig()\uff0cfine()\uff0cfiner()\uff0cfinest()\u65b9\u6cd5\u3002finest()\u65b9\u6cd5\u7528\u6765\u8bb0\u5f55\u6700\u597d\u7684\u4fe1\u606f\uff0c\u800csever()\u65b9\u6cd5\u7528\u6765\u8bb0\u5f55\u6700\u4e25\u91cd\u7684\u4fe1\u606f\u3002<\/p>\n
\u4f7f\u7528Log4J \u6846\u67b6\u6765\u5c06\u6d88\u606f\u8bb0\u5f55\u5728\u4e0d\u540c\u7684\u6587\u4ef6\u4e2d\uff0c\u8fd9\u4e9b\u6d88\u606f\u57fa\u4e8e\u4e25\u91cd\u7a0b\u5ea6\u548c\u91cd\u8981\u6027\u6765\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n
\u8c03\u8bd5\u5de5\u5177<\/strong><\/div>\nNetBeans\u662f\u6811\u5f62\u7ed3\u6784\uff0c\u662f\u5f00\u6e90\u7684Java\u7efc\u5408\u5f00\u53d1\u73af\u5883\uff0c\u652f\u6301\u5f00\u53d1\u72ec\u7acb\u7684Java\u5e94\u7528\u7a0b\u5e8f\u548c\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f\uff0c\u540c\u65f6\u4e5f\u652f\u6301JSP\u8c03\u8bd5\u3002<\/p>\n
NetBeans\u652f\u6301\u5982\u4e0b\u51e0\u4e2a\u57fa\u672c\u7684\u8c03\u8bd5\u529f\u80fd\uff1a<\/p>\n
1.\u65ad\u70b9<\/p>\n
2.\u5355\u6b65\u8ddf\u8e2a<\/p>\n
3.\u89c2\u5bdf\u70b9<\/p>\n
\u8be6\u7ec6\u7684\u4fe1\u606f\u53ef\u4ee5\u67e5\u770bNetBeans\u4f7f\u7528\u624b\u518c\u3002<\/p>\n
\u4f7f\u7528JDB Debugger<\/strong><\/div>\n\u53ef\u4ee5\u5728JSP\u548cservlets\u4e2d\u4f7f\u7528jdb\u547d\u4ee4\u6765\u8fdb\u884c\u8c03\u8bd5\uff0c\u5c31\u50cf\u8c03\u8bd5\u666e\u901a\u7684\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u3002<\/p>\n
\u901a\u5e38\uff0c\u6211\u4eec\u76f4\u63a5\u8c03\u8bd5sun.servlet.http.HttpServer \u5bf9\u8c61\u6765\u67e5\u770bHttpServer\u5728\u54cd\u5e94HTTP\u8bf7\u6c42\u65f6\u6267\u884cJSP\/Servlets\u7684\u60c5\u51b5\u3002\u8fd9\u4e0e\u8c03\u8bd5applets\u975e\u5e38\u76f8\u4f3c\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff0capplets\u7a0b\u5e8f\u5b9e\u9645\u8c03\u8bd5\u7684\u662fsun.applet.AppletViewer\u3002<\/p>\n
\u5927\u90e8\u5206\u8c03\u8bd5\u5668\u5728\u8c03\u8bd5applets\u65f6\u90fd\u80fd\u591f\u81ea\u52a8\u5ffd\u7565\u6389\u4e00\u4e9b\u7ec6\u8282\uff0c\u56e0\u4e3a\u5b83\u77e5\u9053\u5982\u4f55\u8c03\u8bd5applets\u3002\u5982\u679c\u60f3\u8981\u5c06\u8c03\u8bd5\u5bf9\u8c61\u8f6c\u79fb\u5230JSP\u8eab\u4e0a\uff0c\u5c31\u9700\u8981\u505a\u597d\u4ee5\u4e0b\u4e24\u70b9\uff1a<\/p>\n
1.\u8bbe\u7f6e\u8c03\u8bd5\u5668\u7684classpath\uff0c\u8ba9\u5b83\u80fd\u591f\u627e\u5230sun.servlet.http.Http-Server \u548c\u76f8\u5173\u7684\u7c7b\u3002<\/p>\n
2.\u8bbe\u7f6e\u8c03\u8bd5\u5668\u7684classpath\uff0c\u8ba9\u5b83\u80fd\u591f\u627e\u5230\u60a8\u7684JSP\u6587\u4ef6\u548c\u76f8\u5173\u7684\u7c7b\u3002
\n\u8bbe\u7f6e\u597dclasspath\u540e\uff0c\u5f00\u59cb\u8c03\u8bd5sun.servlet.http.Http-Server \u3002\u60a8\u53ef\u4ee5\u5728JSP\u6587\u4ef6\u7684\u4efb\u610f\u5730\u65b9\u8bbe\u7f6e\u65ad\u70b9\uff0c\u53ea\u8981\u4f60\u559c\u6b22\uff0c\u7136\u540e\u4f7f\u7528\u6d4f\u89c8\u5668\u53d1\u9001\u4e00\u4e2a\u8bf7\u6c42\u7ed9\u670d\u52a1\u5668\u5c31\u5e94\u8be5\u53ef\u4ee5\u770b\u89c1\u7a0b\u5e8f\u505c\u5728\u4e86\u65ad\u70b9\u5904\u3002<\/p>\n
\u4f7f\u7528\u6ce8\u91ca<\/strong><\/div>\n\u7a0b\u5e8f\u4e2d\u7684\u6ce8\u91ca\u5728\u5f88\u591a\u65b9\u9762\u90fd\u5bf9\u7a0b\u5e8f\u7684\u8c03\u8bd5\u8d77\u5230\u4e00\u5b9a\u7684\u5e2e\u52a9\u4f5c\u7528\u3002\u6ce8\u91ca\u53ef\u4ee5\u7528\u5728\u8c03\u8bd5\u7a0b\u5e8f\u7684\u5f88\u591a\u65b9\u9762\u4e2d\u3002<\/p>\n
JSP\u4f7f\u7528Java\u6ce8\u91ca\u3002\u5982\u679c\u4e00\u4e2aBUG\u6d88\u5931\u4e86\uff0c\u5c31\u8bf7\u4ed4\u7ec6\u67e5\u770b\u60a8\u521a\u6ce8\u91ca\u8fc7\u7684\u4ee3\u7801\uff0c\u901a\u5e38\u90fd\u80fd\u627e\u51fa\u539f\u56e0\u3002<\/p>\n
\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7684\u5934\u6a21\u5757<\/strong><\/div>\n\u6709\u65f6\u5019\uff0c\u5f53JSP\u6ca1\u6709\u6309\u7167\u9884\u5b9a\u7684\u65b9\u5f0f\u8fd0\u884c\u65f6\uff0c\u67e5\u770b\u672a\u52a0\u5de5\u7684HTTP\u8bf7\u6c42\u548c\u54cd\u5e94\u4e5f\u662f\u5f88\u6709\u7528\u7684\u3002\u5982\u679c\u5bf9HTTP\u7684\u7ed3\u6784\u5f88\u719f\u6089\u7684\u8bdd\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u89c2\u5bdfrequest\u548cresponse\u7136\u540e\u770b\u770b\u8fd9\u4e9b\u5934\u6a21\u5757\u5230\u5e95\u600e\u4e48\u4e86\u3002<\/p>\n
\u91cd\u8981\u8c03\u8bd5\u6280\u5de7<\/strong><\/div>\n\u8fd9\u91cc\u6211\u4eec\u518d\u900f\u9732\u4e24\u4e2a\u8c03\u8bd5JSP\u7684\u5c0f\u6280\u5de7\uff1a<\/p>\n
1.\u4f7f\u7528\u6d4f\u89c8\u5668\u663e\u793a\u539f\u59cb\u7684\u9875\u9762\u5185\u5bb9\uff0c\u7528\u6765\u533a\u5206\u662f\u5426\u662f\u683c\u5f0f\u95ee\u9898\u3002\u8fd9\u4e2a\u9009\u9879\u901a\u5e38\u5728View\u83dc\u5355\u4e0b\u3002<\/p>\n
2.\u786e\u4fdd\u6d4f\u89c8\u5668\u5728\u5f3a\u5236\u91cd\u65b0\u8f7d\u5165\u9875\u9762\u65f6\u6ca1\u6709\u6355\u83b7\u5148\u524d\u7684request\u8f93\u51fa\u3002\u82e5\u4f7f\u7528\u7684\u662fNetscape Navigator\u6d4f\u89c8\u5668\uff0c\u5219\u7528Shift-Reload\uff1b\u82e5\u4f7f\u7528\u7684\u662fIE\u6d4f\u89c8\u5668\uff0c\u5219\u7528Shift-Refresh\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u8981\u6d4b\u8bd5\/\u8c03\u8bd5\u4e00\u4e2aJSP\u6216servlet\u7a0b\u5e8f\u603b\u662f\u90a3\u4e48\u7684\u96be\u3002JSP\u548cServlets\u7a0b\u5e8f\u8d8b\u5411\u4e8e\u7275\u6d89\u5230\u5927\u91cf\u5ba2\u6237\u7aef\/\u670d […]<\/p>\n","protected":false},"author":321,"featured_media":223365,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-223450","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=223450"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223450\/revisions"}],"predecessor-version":[{"id":223455,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223450\/revisions\/223455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/223365"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=223450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=223450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=223450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}