Java Tutorial/Servlet/Exception
Версия от 17:44, 31 мая 2010; (обсуждение)
Generate Servlet Exception
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
throw new NullPointerException();
}
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
ServletOutputStream out = res.getOutputStream();
res.setContentType("text/html");
out.println("<html><head><title>Exception Thrower</title></head>");
out.println("<body>You"ll never see this!</body></html>");
}
}