• 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

jsp:useBean and jsp:getProperty

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I'm trying to learn how to use bean-related standard actions. Would someone please help me resolving this issue? This is the error I'm getting:

Dec 10, 2011 3:52:57 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /web/beerResult.jsp(24,17) The value for the useBean class attribute com.example.domain.Beer is invalid.
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1233)
....

Here's a partial example of what I've done:



Controller:


JSP:


Thanks for reviewing my code and any feedback you can provide.
 
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
Is the bean's class file in the correct location?
 
Bear Bibeault
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
And, is the scriptlet in your JSP just for testing purposes? Scriptlets are no longer acceptable in JSP pages.
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear for your reply. In response to your question, yes and yes. The bean class is here: C:\apache-tomcat-6.0.33\webapps\MyServletApp\WEB-INF\classes\com\example\domain.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are three requirements for a java object to be recognised as a Bean

- has to compile (duh)
- has to be in a package
- has to have a public 'default' constructor that takes no arguments.
- should be Serializable.

Your class is missing the third requirement.
ie



One other thing: A JSP implicitly defines a variable called "session", so you shouldn't need to declare your own version of it, but rather use the standard one.
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stefan!!! I'll give this a try and keep these requirements in memory too!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic