Websphere 异常处理
从安全角度来看,使用 Websphere 处理应用程序错误的最佳解决方案是什么?
我一直在考虑创建一个类,每次生成应用程序错误时都会调用该类,记录错误并向用户显示通用错误消息。
在 PHP 中,这可以使用 set_exception_handler() 函数来实现。是否有类似的 websphere 可以在 web.xml 中配置?
我在互联网上找到了这样的代码:
<error-page>
<error-code>500</error-code>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>
但这仅适用于“500”HTTP 错误代码。我真的想要一些通用的东西来捕捉一切。类似于实现某个接口的类,该接口可以访问有关错误的所有信息。
感谢您抽出时间。
From a security standpoint, what is the best solution to handle application errors with Websphere?
I've been thinking of creating a class that is called every time an application error is generated, log the error and display a generic error message to the users.
In PHP this can be achieved using the set_exception_handler() function. Is there something similar for websphere that could be configured in the web.xml?
I've found codes like this on the internet:
<error-page>
<error-code>500</error-code>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>
But that would only work with "500" HTTP error codes. I really want something generic that catches everything. Something like a class that implements a certain interface which can have access to all information about the error.
Thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这也可以在 web.xml 中找到:
除其他地方外,这还用在 此 WebSphere 示例。 JEE5 教程也可能有助于设置此功能,特别是关于 映射 servlet 异常 和 创建 JSP 错误页面。
本质上,所有异常都应该包含在 ServletExceptions< 中/a> 并且您映射到的 JSP 应该在页面的最顶部设置
<%@ page isErrorPage="true" %>
。This is also available in web.xml:
Among other places, this is used in this WebSphere example. The JEE5 tutorial may also be helpful in setting this up, particularly the part about mapping servlet exceptions and creating JSP error pages.
Essentially, all of your exceptions should be wrapped in ServletExceptions and the JSP you map to should have
<%@ page isErrorPage="true" %>
set at the very top of the page.