• 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

Trying to use a bean

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to learn how to use beans with servlets and JSP. If you have a link which walks through some simple examples that would be great. Currently, I am unable to compile the class. Here is the error:



Here is the code I am trying to use to access the bean:




And here is the bean itself, located in "Source packages" package "Testing" called TestBean.java

 
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
The JSP FAQ covers this in detail.
 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. I am now looking at this page trying to get ideas:

http://faq.javaranch.com/view?BeansNotFound


I can find the TestBean.class in the folder
\project\build\web\WEB-INF\classes

But it is not in the folder

\project\web\WEB-INF\classes

Should one manually copy the file over from one directory to the other? I am not sure what I am missing actually.



I have put them into a package as suggested by this FAQ

http://faq.javaranch.com/view?PackageYourBeans

I don't see any other FAQ's related to this but thanks for your help.
 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to your tip and some web searching, I found I was missing the following things:

I DID have to copy the class file from the build directory to the directory
project\web\WEB-INF\classes\Testing

This seems wierd. Why doesn't it build it in the correct place?

Also I had to change my includes to read as follows:



The package I guess is the directory really where the thing lives, and it uses the name to look in that directory.
 
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

Originally posted by Tom Joiner:
Why doesn't it build it in the correct place?



What is it?

<%@page import="Testing.TestBean" %>



You should follow accepted conventions and use all lowercase for package names.
reply
    Bookmark Topic Watch Topic
  • New Topic