ServletException, HttpServletResponse and HttpServletRequest cannot be resolved to a type

compiler-errors, eclipse, jakarta-ee, servlets

Solution

Two possible issues could be

- you either forgot to include Servlet jar in your classpath

- you forgot to import it in your Servlet class

To include Servlet jar in your class path in eclipse, Download the latest Servlet Jar and configure using buildpath option. look at this Link for more info.

If you have included the jar make sure that your import is declared.

import javax.servlet.http.HttpServletResponse

Problem

I got an error while creating a servlet in eclipse like Multiple markers at this line - ServletException cannot be resolved to a type - HttpServletResponse cannot be resolved to a type - HttpServletRequest cannot be resolved to a type

Original source

Related problems