Hi all,
In the Sample Chapter of Professional SCWCD have a question (#8):
What is the result if the following
servlet's doPost() method is called? Assume the response has been commited as a result the writer.flush() method. Select one correct answer:
public class ServletY extends HttpServlet{
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
PrintWriter writer = res.getWriter();
writer.println("Hello World");
writer.flush();
res.sensError(HttpServletResponse.SC_FORBIDDEN, "bang!");
}
}
a. A java.lang.IllegalStateException is thrown
b. A NullPointerException is thrown
c. The browser displays SC?_FORBIDDEN error page
I Think and have gotten none above, i'v gotten "Hello Word".
What is the correct answer?