I have created a Web Project. I already have a simple java project, that has a public class A.
I have included this java project in the classpath of this web project. In the welcome jsp of this project, i have imported this class through the page directive and then in the scriptlet i create an instance of this class.
When i execute the application, i get cannot resolve symbol A. What could be the problem?
test_project.war\_test1.java:4: '.' expected import A; ^ An error occurred between lines: 22 and 27 in the jsp file: /test1.jsp Generated servlet error:
cannot resolve symbol symbol : class A location: class org.apache.jsp._test1 A ab = new A(); ^ An error occurred between lines: 22 and 27 in the jsp file: /test1.jsp Generated servlet error:
test_project.war\_test1.java:78: cannot resolve symbol symbol : class A location: class org.apache.jsp._test1 A ab = new A(); ^ 3 errors
Note: Class A is just a empty class in the simple java project.There are no compilation errors, and this is the runtime error.
William Brogden
,
Author and all-around good cowpoke
Put class A in a package and correctly import the package into the JSP. When classes dont have an explicit package the JVM looks in the "current" directory - something you have no control over in the servlet/jsp environment. ALL classes used in servlets/jsp should be in packages to avoid hard to understand bugs. Bill
I had tested putting Class A in a package 'tutorial.databeans'(in the simple java project). And i get the same error.
What i noticed is that the class in the default package appears in the WEB-INF/classes folder of the web project, whereas i could not find the class in the package. Why could this be?
Originally posted by geetu lalchandani: I had tested putting Class A in a package 'tutorial.databeans'(in the simple java project). And i get the same error.
What i noticed is that the class in the default package appears in the WEB-INF/classes folder of the web project, whereas i could not find the class in the package. Why could this be?
yes , i have done both. Compiled the class and well as changed the import as. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="tutorial.databeans.A" %>
Post by:autobot
My cellmate was this tiny ad:
a bit of art, as a gift, the permaculture playing cards