Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Jasper Error while importing classes without packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Jasper Error while importing classes without packages" Watch "Jasper Error while importing classes without packages" New topic
Author

Jasper Error while importing classes without packages

Sarath PS
Greenhorn

Joined: Oct 22, 2004
Posts: 11
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/index_jsp.java:6: '.' expected
import Account;
^
1 error


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:315)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:406)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:463)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:430)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


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

Sarath
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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.
Bill
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Error while importing classes without packages