JSP 应用程序的浏览器插件或调试面板

发布于 2024-10-19 20:43:26 字数 296 浏览 0 评论 0原文

我已经习惯了 Django 漂亮的错误页面及其上的所有详细信息,所以我真的很苦恼 Tomcat/JSP 无法对由 JSP 标签拼写错误等引起的基本 JasperException 做同样的事情。所有内容都会进入 localhost.log,并且很难检测或读取。

有没有浏览器插件或者小型 JSP 应用程序可以很好地做到这一点?

我可以 try/catch JSP 中的所有异常并将其传递给该应用程序/插件,因此它可以很好地在浮动 div 或其他内容中显示错误详细信息。

I so used to Django'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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救赎№ 2024-10-26 20:43:26

我不知道有这样的事情。我怀疑很难比现在做得更好;例如,针对 JSP 编译错误的 HTTP 500 响应,以及...针对 JSP 执行错误,没有向浏览器传递任何有用的信息。

根本问题是Servlet和JSP的实现模型。基本上,servlet 一旦打开输出流就会“提交”HTTP 响应。一旦发生这种情况,就无法更改响应标头。您无法更改响应状态代码。您无法更改内容类型标头。

如果在 JSP 或 Tag 执行期间抛出一些异常,则没有好的方法可以将其报告给浏览器。很可能响应是使用“text/html”内容类型提交的,并且 JSP 已开始编写 HTML。无法撤消。为时已晚。对不起。

如果 JSP 无法可靠地将诊断消息传递给浏览器,那么浏览器插件将无济于事。

“修复”此问题的唯一方法是 JSP 将响应正文写入内存缓冲区,并且仅在完成后将其复制到输出流,并确定不会引发任何异常。由于性能影响,这无法修复无法飞行的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文