📄 webapp9.html
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>Debugging Web Modules</title> <link rel="StyleSheet" href="document.css" type="text/css" media="all" /> <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" /> <link rel="Table of Contents" href="J2EETutorialTOC.html" /> <link rel="Previous" href="WebApp8.html" /> <link rel="Next" href="WebApp10.html" /> <link rel="Index" href="J2EETutorialIX.html" /> </head> <body> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="WebApp8.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="WebApp10.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <blockquote><a name="wp191914"> </a><h2 class="pHeading1">Debugging Web Modules</h2><a name="wp189414"> </a><h3 class="pHeading2">Using the Server Log</h3><a name="wp189427"> </a><p class="pBody">One way to debug Web modules is to look at the server log in <code class="cCode"><</code><code class="cVariable">J2EE_HOME</code><code class="cCode">>/domains/domain1/logs/server.log</code>. The log contains output from the application server and your Web modules. You can log messages from any Java class your Web modules with <code class="cCode">System.out.println</code> and the Java Logging APIs (documented at <code class="cCode"><a href="http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/index.html" target="_blank">http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/index.html</a></code>) and from Web components with the <code class="cCode"><a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#log(java.lang.String,java.lang.Throwable)" target="_blank">ServletContext.log</a></code> method.</p><a name="wp214673"> </a><p class="pBody">If you start the server with the <code class="cCode">--verbose</code> flag, all logging and debugging output will appear on the terminal window or command prompt and the server log. If you start the server in the background, debugging information is only available in the log. You can view the server log with a text editor or with the Admin Console log viewer. To use the log viewer:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp214674"> </a><div class="pSmartList1"><li>Select the Application Server node.</li></div><a name="wp217445"> </a><div class="pSmartList1"><li>Select the Logging tab.</li></div><a name="wp214675"> </a><div class="pSmartList1"><li>Click the Open Log Viewer button.</li></div><a name="wp214676"> </a><div class="pSmartList1"><li>Specify any constraints on the entries you want to see.</li></div><a name="wp214677"> </a><div class="pSmartList1"><li>Click the Search button.</li></div></ol></div><a name="wp214678"> </a><p class="pBody">Note that it's not possible to see messages logged with <code class="cCode">System.out.println</code> in the Admin Console log viewer. If you prefer to use the Admin Console log viewer, you will need to use the J2SE Logging API to log your messages.</p><a name="wp191930"> </a><h3 class="pHeading2">Using a Debugger</h3><a name="wp191931"> </a><p class="pBody">The J2EE 1.4 Application Server supports the Java Platform Debugger Architecture (JPDA). Using JPDA, you can configure the application server to communicate debugging information via a socket. In order to debug a Web module using a debugger:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp214724"> </a><div class="pSmartList1"><li>Enable debugging in the application server with the Admin Console as follows: </li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp214725"> </a><div class="pSmartList2"><li>Select the Application Server node.</li></div><a name="wp214726"> </a><div class="pSmartList2"><li>Select the JVM Settings tab. The default debug options are set to:</li></div><a name="wp214727"> </a><p class="pBodyRelative"><code class="cCode">-Xdebug -Xrunjdwp:transport=dt_socket,server=y,<br /> suspend=n,address=1044</code></p><a name="wp214728"> </a><p class="pBodyRelative">As you can see, the default debugger socket port is 1044, but you can change it to anything not already used by the application server or another service.</p><a name="wp214729"> </a><div class="pSmartList2"><li>Check the Enabled box of the Debug field. </li></div><a name="wp214730"> </a><div class="pSmartList2"><li>Click the Save button.</li></div></ol></div><a name="wp214731"> </a><div class="pSmartList1"><li>Stop the server and then start it.</li></div><a name="wp192367"> </a><div class="pSmartList1"><li>Compile your Java source with the <code class="cCode">-g</code> flag.</li></div><a name="wp191944"> </a><div class="pSmartList1"><li>Deploy your Web module.</li></div><a name="wp192372"> </a><div class="pSmartList1"><li>Start a debugger and connect to the debugger socket at whatever port you set when you enabled debugging.</li></div></ol></div> </blockquote> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="WebApp8.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="WebApp10.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -