MyServlet.java Source code

Java tutorial

Introduction

Here is the source code for MyServlet.java

Source

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>");

    }
}