Anonymous Dodo
Anonymous Dodo

Reputation: 271

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"
    pageEncoding="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">
<html>

Upvotes: 0

Views: 1242

Answers (1)

Jesper
Jesper

Reputation: 207006

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" %>

Upvotes: 2

Related Questions