Bom dia todos. Estou fazendo alguns simulados para a certificação SCWCD e me deparei com a questão abaixo:
package com.javaranch;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PostServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>\n <body>\n");
out.println(" <h2>\n Hello World\n </h2>\n");
out.println(" </body>\n</html>\n");
out.flush();
out.close();
}
}
What is the result of compiling the above Servlet and accessing it by typing:
"http://www.javaranch.com/test/HelloServlet"
into the address field of a browser
Choises:
1- The code fails to compile.
2- The browser displays “Hello World”
3- The server will not find the Servlet due to an incorrect URL.
4- An error page is returned from the Server.
A resposta do exame é a número 4, mas eu colocando o código no eclipse e compilando com o tomcat 7.0 e mapeando certinho a url a resposta deu Hello World queria saber se este servlet tem algum erro nele. Desde já obrigado.