This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to compile class for JSP:

 
Singh Harmeet
Ranch Hand
Posts: 115
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make your class public. That's always required to be able to import a class from a different package.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic