我在 JSP 中有以下代码片段:我们可以用服务器端包含替换它吗?具体来说,就是调用 Servlet Context 对象和 try-catch 块。
请指教 :
提前致谢。
<%
String includeURL = "";
if (getServletConfig().getServletContext().getServletContextName().startsWith("internal")) {
includeURL = "/test/index.inc";
} else {
includeURL = "/testone/index.inc";
}
try {
%><jsp:include page="<%= includeURL %>" flush="true" /><%
} catch (Throwable e) {
out.println("<!-- Could not include file - ERROR: " + e.toString() + " -->");
}
%>