• 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

invalid useBean attribute error

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all, I�m having a problem with a .jsp file that I�m trying to view. It�s from a Sun tutorial and has very little modification to it from the way it was posted on Sun�s site. As a matter of fact, I�ve gone so far as to cut and paste the exact code for the .jsp file, and the .java file that it uses, from Sun's website and I still get the same error.

Anyway, the error is �The value for the useBean class attribute deq.CounterBean is invalid.�. And the code for the two files is:

counter.jsp


CounterBean.java


I�ve placed the CounterBean.java file in a folder called �deq� and it sits one level below the counter.jsp file. I did this as a last ditch effort to make the counter.jsp file see the CounterBean.java file.

I also created a BeanTester.java file that uses the CounterBean.java file. This file sits in the same directory as the counter.jsp file and it worked fine.
 
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

I�ve placed the CounterBean.java file in a folder called �deq� and it sits one level below the counter.jsp file.



Not correct. Your class hierarchy must be rooted at WEB-INF/classes or be within a jar file in the classpath.

So the correct location (relative to the root of your wen app) would be:

/WEB-INF/classes/deq/CounterBean.class

P.S. I doesn't matter where you put the .java file. It must be compiled and its class file placed as above. The container will not automatically compile it the way that it compiles JSP files.
[ October 19, 2004: Message edited by: Bear Bibeault ]
 
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
You might want to look into Ant for a great tool to help you build your app; including compiling your java beans, servlets and other classes and placing the resulting .class file in the required locations.
 
Chris Staten
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still getting the same error. I tried moving a copy of the WEB-INF directory and all of it's sub folders out of the Tomcat directory as well as simply puting my project into the WEB-INF/classes directory inside Tomcat.

I think I'm going to start reading my new Head First Servlets & JSP book and come back to this after I have a better understanding of JSP.
 
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
One thing about web apps is that they must follow a certain pattern in order to work. Making yourself aware of that pattern is probably a great idea.
 
reply
    Bookmark Topic Watch Topic
  • New Topic