scwcd的考试,测试代码,如果希望参加此类考试将非常的有帮助
源代码在线查看: progexception3.java
package scwcd.lab05;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ProgException3 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String[] array1 = new String[3];
try {
array1[4] = "some message...";
} catch (ArrayIndexOutOfBoundsException e) {
ServletContext context = getServletContext();
RequestDispatcher errorPage
= context.getNamedDispatcher("ProgExceptionHandler");
request.setAttribute("request_uri",
request.getRequestURI());
request.setAttribute("thrown_exception",e);
errorPage.forward(request, response);
}
}
}