1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 24 39 40 public class ErrorPage05 extends HttpServlet { 41 42 public void doGet(HttpServletRequest request, HttpServletResponse response) 43 throws IOException, ServletException { 44 45 response.setContentType("text/plain"); 46 PrintWriter writer = response.getWriter(); 47 48 writer.println("ErrorPage05 FAILED - Original response returned"); 50 51 String type = request.getParameter("type"); 53 if ("Arithmetic".equals(type)) { 54 throw new ArithmeticException 55 ("ErrorPage05 Threw ArithmeticException"); 56 } else if ("Array".equals(type)) { 57 throw new ArrayIndexOutOfBoundsException 58 ("ErrorPage05 Threw ArrayIndexOutOfBoundsException"); 59 } else if ("Number".equals(type)) { 60 throw new NumberFormatException 61 ("ErrorPage05 Threw NumberFormatException"); 62 } 63 64 } 65 66 } 67 | Popular Tags |