Failed to get servlet import in my maven project

I am working on a servlet class but am getting the following errors. From my research that I did, I realized that import is required for me. The problem is that I cannot add import. This is my servlet class.

public class School extends HttpServlet { public void doGet(HtttpServletRequest request, HttpServletResponse response) throw ServletException, IOException { String name = request.getParameter('name'); PrintWriter writer = response.getWriter(); writer.ptintln("<html><body>" + new Date() +"<html></html>"); } } 
+5
source share
2 answers

You can add imports at the top of the page as shown below

 import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.ejb.EJB; import javax.security.auth.message.callback.PrivateKeyCallback.Request; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 
+4
source

Hover over the part where it indicates that there is an error. You will see a menu with the import option or some other suggestions that you can try.

+3
source

All Articles