• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with using beans on Tomcat  RSS feed

 
jack chu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a java bean in WEB-INF/classes directory.
I'm trying use that class in a jsp file on a different directory, and it doesn't seem to know where the java bean is. Where should I place this java bean class at?
Here is the error:
org.apache.jasper.JasperException: Unable to compile class for JSP/usr/java/jakarta-tomcat-3.2.1/work/stage.icarian.com_8080/_0002fproducts_0002fpre_0005fdemo_0005fform_0002ejsppre_0005fdemo_0005fform_jsp_24.java:66: Class products.PartnerBean not found.
PartnerBean pBean = new PartnerBean();
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try adding subdirectory under classes
.....classes/products/bean_class
I am new to this stuff, so I am not sure if that is your problem.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another common problem - you must declare the complete package and filename in your jsp:useBean tag, that is in addition to importing it.
Bill
 
Ashwin Asani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also give the classpath till your package directory in tomcat.bat file.
This should definetly work because the server picks up the classpath from this file.
 
Wayne Hefner
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way I normally handle the beans is to create a jar file that contains the beans and add that jar file to the classpath in tomcat.sh
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this ....
1. create a jar file of the all the beans that you are using for the particular application.
2. create a folder by the name "lib" under the root of your context and place the jar file in this folder.hope that helps
Samith.P.Nambiar
<pre>
\```/
(o o) harder u try luckier u get
-------oOO--(_)--OOo----------------------------
</pre>
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right, you can :
(1) place your JavaBeans in a .JAR file under the WEB-INF/lib directory of your web application, or alternatively you can
(2) place the class files (in the appropriate package/directory structure) under the WEB-INF/classes directory of your web application.
Regards
Simon
------------------
Simon Brown
Author of Professional JSP 2nd Edition
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!