Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to use a bean  RSS feed

 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP FAQ covers this in detail.
 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!