⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 progexception2.java

📁 scwcd的考试,测试代码,如果希望参加此类考试将非常的有帮助
💻 JAVA
字号:
package scwcd.lab05;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ProgException2 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) {
      handlerMethod(request, response);
    }
  }
  
  public void handlerMethod(HttpServletRequest request,
                            HttpServletResponse response)
              throws IOException {
    response.setContentType("text/html; charset=GB2312");
    PrintWriter out = response.getWriter();
    out.println("<HTML><BODY>");
    out.println(request.getRequestURI() + " 运行错误!");
    out.println("<BR><BR>");
    out.println("错误原因:超出数组索引值的存取范围。");
    out.println("</BODY></HTML>"); 	
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -