Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get Servlet import on my maven project

I am working on a servlet class but I am getting the following errors. From my research that I have made I realized that it is require for me to do some imports. The problem is I cannot add imports. 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>");
     }
}
like image 960
S. Kiragu Avatar asked Jun 15 '16 13:06

S. Kiragu


2 Answers

You can add imports at the beginning of the page like depicted 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;
like image 170
Ndirangu Avatar answered Sep 27 '22 21:09

Ndirangu


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

like image 29
Mozzay Avatar answered Sep 27 '22 22:09

Mozzay