Search code examples
eclipseservletsjakarta-eecompiler-errors

ServletException, HttpServletResponse and HttpServletRequest cannot be resolved to a type


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

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