run_error.xtp

来自「解压在c盘」· XTP 代码 · 共 69 行

XTP
69
字号
<s1 title="Runtime Errors"><p>When the Java code throws an exception, Resin will immediately stop thescript and report the error to the browser.  For example, we'll forcea null pointer exception:</p><example title='buggy.jsp'>&lt;%@ page language=java %&gt;&lt;% String foo = null; %&gt;&lt;%= foo.length() %&gt;</example><p>The reported error looks something like the following:<results border=3>500 Servlet Exceptionjava.lang.NullPointerException  at work.test.buggy$_jsp._jspService(/test/buggy.jsp:4)  at com.caucho.jsp.JavaPage.service(JavaPage.java:72)  at com.caucho.jsp.QServlet.service(QServlet.java:152)  at com.caucho.server.http.Invocation.service(Invocation.java:183)  at com.caucho.server.http.Request.dispatch(Request.java:174)  at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:151)  at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:114)  at com.caucho.server.TcpConnection.run(TcpConnection.java:115)  at java.lang.Thread.run(Thread.java)</results><p>The most important part of the error message is the location:`<var>/test/buggy.jsp:4</var>'.  Resin translates the line in thegenerated Java code back to the JSP line.</p><s2 title="What if I get 'Compiled Code' instead oflines?"><p>You should run Resin with -nojit, turning off the just-in-timecompiler, when developing so you can see the proper line numbers.That alone will make development much easier.</p><p>Java VMs with just-in-time compilers (jits) compile Javabytecodes to machine code.  This makes Java almost as fast as C, butremoves all the line numbers.  Running with -nojit will disable thecompiler.  When your code is completely debugged, you can run with thecompiler enabled.</p><p>To see the difference, here's the same stack trace with a JITenabled:</p><results>500 Servlet Exceptionjava.lang.NullPointerException at work.test.buggy$_jsp._jspService(Compiled Code) at com.caucho.jsp.JavaPage.service(Compiled Code) at com.caucho.jsp.QServlet.service(Compiled Code) at com.caucho.server.http.Invocation.service(Compiled Code) at com.caucho.server.http.Request.dispatch(Compiled Code) at com.caucho.server.http.HttpRequest.handleRequest(Compiled Code) at com.caucho.server.http.HttpRequest.handleConnection(Compiled Code) at com.caucho.server.TcpConnection.run(Compiled Code) at java.lang.Thread.run(Compiled Code)</results></s2></s1>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?