Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jasper Error while importing classes without packages

Sarath PS
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all ,
I created a jsp file that uses some classes( with out any package).
But when i try to execute, Jasper gives me error like this.

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] Compiling 1 source file

/usr/java/tomcat-5.0.25/work/Catalina/localhost/myapp/org/apache/jsp/ '.' expected
import Account;
1 error


Any body know any work around with out changing the package structure ? .This is because , I don't have the source code for the application.

Thanks in advance

William Brogden
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a work-around. That is because the JVM looks for classes in the "default" package in the "current" directory. You might be able to control the current directory in a special case but in the general servlet environment you have no control.
I suppose you might be able to "hide" the Account class reference inside a wrapper class in a package, but then you would have to provide for a custom classloader to get a copy of the Account class.
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about the last part of William's last sentence...

Then in your JSP you'd be using 'mypackage.Account2', which is packaged. The JSP would produce a java source file that imports mypackage.Account2, and after that (runtime), the classloader would be able to find both Account and mypackage.Account2.
[ October 23, 2004: Message edited by: Mike Curwen ]
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!