This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JSP and the fly likes Problems of importing a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problems of importing a class" Watch "Problems of importing a class" New topic

Problems of importing a class

Ego Tang

Joined: Oct 01, 2002
Posts: 11
Hi ranchers,
I tried to import a class(e.g. test.class)from JSP and put it in ..\WEB-INF\classes file. However, it got a complilation error:
"org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\ '.' expected
[javac] import test;
and my page directive is:
<%@ page import="test" %>
I compiled it fine in tomcat 4.0 but failed in 4.1. Can anyone tell me what happened?
Many thanks!
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
It looks like the Jasper JSP compiler is objecting to a class that is not contained in a package.
It is always recommended that you create classes in a package hierarchy. Have you tried putting you Test.class in a package ?

Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
There is a Bug?? Feature?? with JSP's, JSP's cannot fine classes that are not in a package! Change your class to have a package such as test so the fully qualified name of the class is test.test and inport this.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Ego Tang

Joined: Oct 01, 2002
Posts: 11
I'd put my class in a package and it worked fine!
Many thanks!
Have you checked out Aspose?
subject: Problems of importing a class
It's not a secret anymore!