Karan Luthria Karan Luthria - 3 months ago 6x
Java Question

The import src cannot be resolved

I'm a beginner in JSP but understand Java and HTML. I am running into this error when trying to run a JSP file in Eclipse on line three, can someone please help?

The following link is my Path Layout

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@page import = "src/Person.java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


An import directive in a JSP is just like an import statement in a Java source file: it expects a fully-qualified class name, not a path to a source file.

First of all, you must put your class Person in a package. Put the source file MyPerson.java in a directory mypackage, for example, and add a package statement at the top of the source file:

package mypackage;

Then, you can import it in the JSP by specifying the fully-qualified class name:

<%@page import="mypackage.Person" %>