开发者

Browser plugin or debug panel for JSP applications

开发者 https://www.devze.com 2023-02-14 11:35 出处:网络
I so used to Dj开发者_如何学运维ango\'s nice error page with all the details on it so I\'m really struggling with Tomcat/JSP inability to do the same thing with basic JasperExceptions caused by JSP ta

I so used to Dj开发者_如何学运维ango's nice error page with all the details on it so I'm really struggling with Tomcat/JSP inability to do the same thing with basic JasperExceptions caused by JSP tag misspelling, etc. They all go into localhost.log and they are very hard to detect or read through.

Is there a browser plugin or maybe a small JSP app to do that nicely?

I can try/catch all exceptions in my JSPs and pass it to that app/plugin, so it can nicely display error details in floating div or something.


I'm not aware of any such thing. And I suspect that it would be difficult to do much better that the current; e.g. HTTP 500 responses for JSP compilation errors, and ... nothing useful delivered to the browser for a JSP execution error.

The fundamental problem is the implementation model of Servlets and JSPs. Basically, a servlet "commits" an HTTP response as soon as it opens the output stream. Once this happens, there is no way to change the response headers. You can't change the response status code. You can't change the content type header.

If some exception gets thrown during the execution of a JSP or a Tag, there is no good way for this to be reported to the browser. The chances are that the response is committed with a "text/html" content type, and that the JSP has started writing the HTML. Can't undo. Too late. Sorry.

And if the JSP cannot reliably deliver a diagnostic message to the browser, a browser plugin won't help.

The only way to "fix" this would be for JSPs to write the response body to an in-memory buffer, and only copy that to the output stream once it had finished, and determined that no exceptions were going to be thrown. That wouldn't fix would not fly because of the performance implications.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号