File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Unable to compile class for JSP: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to compile class for JSP:" Watch "Unable to compile class for JSP:" New topic
Author

Unable to compile class for JSP:

Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

this is my code





this error is generated when i try to execute this file:-

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 6 in the jsp file: /demo.jsp
The type BeanDemo is not visible
3: <html>
4: <body>
5: <p> To Set The Attribute </p>
6: <% BeanDemo b = new BeanDemo(); %>
7: </body>
8: </html>
9:


An error occurred at line: 6 in the jsp file: /demo.jsp
The type BeanDemo is not visible
3: <html>
4: <body>
5: <p> To Set The Attribute </p>
6: <% BeanDemo b = new BeanDemo(); %>
7: </body>
8: </html>
9:


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

My Class Hirerchy is like project-> WEB-INF -> classes -> com -> example -> transfer


With Regards :-
Harmeet Singh
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4460
    
    8

If that's your exact code, BeanDemo isn't public, so you can't access if from another package (which is what you're doing in a JSP) even with an import statement.
Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

thanks Mr.Matthew Brown , the class is not public .. so the error is produce , thank sir my program is run.....

but sir if my class file in classes directory... and i want to access it , what i do for that, because without import statement in jsp there is error , then what i give the path in import statement ??
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19759
    
  20

Just make your class public. That's always required to be able to import a class from a different package.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to compile class for JSP: