Eu tento abrir o caminho http://localhost:8080/gerenciador/oi mas aparece a mensagem:
java.lang.Error: Unresolved compilation problem: resp cannot be resolved
br.com.alura.gerenciador.servlet.OiMundoServlet.service(OiMundoServlet.java:20)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:770)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Meu código a seguir:
package br.com.alura.gerenciador.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
//oi
@WebServlet(urlPatterns = "/oi")
public class OiMundoServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws IOException {
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<body>");
out.println("Oi mundo!");
out.println("</body>");
out.println("</html>");
}
}