• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jasper compile error

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
i encounter a very strange problem. Every time I want to test a JSP page that imports a JavaBean, I receive the following error message about import declaration.

org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 1 in the jsp file: /addressDisplay.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\java\plateforme\tomcat\work\Standalone\localhost\chapter14\addressDisplay_jsp.java:7: '.' expected
import AddressBean;
^


I'm don't see what is wrong in the declaration of my JSP page:

the code of the bean AdresseBean is the following:

Really I don't understand what's happening.
I would be very grateful for any assistance.
Regards,
Cyril.
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you don't need an import statement if it is just a class/bean. you only use import statements to import packages. from the code you pasted that bean is not in a package.
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
Thanks for your response.
I have tried without the import statement and now there's a problem because the class is not found:


C:\java\plateforme\tomcat\work\Standalone\localhost\chapter14\addressDisplay_jsp.java:42: cannot resolve symbol
symbol : class AddressBean
location: class org.apache.jsp.addressDisplay_jsp
AddressBean address = null;
^


by the way, are you sure we don't need to import the bean, even if it is not part of package?
The code I test come from source code of book SCWCD Exam Study Kit, and the import statement is right in the page JSP.
My Bean class is in WEB-INF/classes directory ...
I'm stuck
Regards,
Cyril.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put your bean in a package. The various servlet containers get freaky about package-less classes. This is just good practice in any case.
bear
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks Bear! It's OK now.. and it's worth knowing it!!
Regards,
Cyril.
reply
    Bookmark Topic Watch Topic
  • New Topic