META-INF.resources.WEB-INF.jsp.500.jsp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ajaxjs-framework2 Show documentation
Show all versions of ajaxjs-framework2 Show documentation
AJAXJS aims to full-stack, not only the server-side framework,
but also integrates the front-end library. It's written in HTML5 + Java, a successor to the JVM platform, efficient, secure, stable, cross-platform and many other advantages, but it abandoned the traditional enterprise architecture brought about by the large and bloated,
emphasizing the lightweight, and fast, very suitable for the Internet fast application.
The newest version!
<%@page pageEncoding="UTF-8" isErrorPage="true" import="java.io.*" trimDirectiveWhitespaces="true"%>
<%!
/**
* 获取相关信息
*
* @param request 请求对象
*/
public static String getSth(HttpServletRequest request, String key) {
Object obj = request.getAttribute(key);
if(obj == null) {
return null;
} else {
return obj.toString().replaceAll("<|>", "");
}
}
/**
* 收集错误信息 输出到网页
*
* @param request 请求对象
*/
public static OutputStream getError(HttpServletRequest request, Throwable ex) {
OutputStream os = new ByteArrayOutputStream();// 创建一个空的字节流,保存错误信息
PrintStream ps = new PrintStream(os);
// 不要用 java 7 的 autoClose,因为要在 tomcat 里面手动打开
try {
// 收集错误信息
ps.println("错误代码: " + getSth(request, "javax.servlet.error.status_code"));
ps.println("异常 Servlet: " + getSth(request, "javax.servlet.error.servlet_name"));
ps.println("出错页面地址: " + getSth(request, "javax.servlet.error.request_uri"));
ps.println("访问的路径: " + getSth(request, "javax.servlet.forward.request_uri"));
ps.println("模板的路径: " + getSth(request, "jsp_path"));
ps.println();
for (String key : request.getParameterMap().keySet()) {
ps.println("请求中的 Parameter 包括:");
ps.println(key + "=" + request.getParameter(key));
ps.println();
}
if (request.getCookies() != null) {
for (Cookie cookie : request.getCookies()) {
ps.println("请求中的 Cookie 包括:");
ps.println(cookie.getName() + "=" + cookie.getValue());
ps.println();
}
}
// javax.servlet.jspException 等于 JSP 里面的 exception 对象
if (ex != null) {
ps.println("堆栈信息");
ex.printStackTrace(ps);
ps.println();
}
return os;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
os.close();
ps.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}%>
错误页面 code:${requestScope['javax.servlet.error.status_code']}
服务端异常-HTTPStatusCode:${requestScope['javax.servlet.error.status_code']}
非常抱歉,服务器运行出错!异常信息:
© 2015 - 2024 Weber Informatics LLC | Privacy Policy