Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Problem creating JavaBeans


Message #1 by "Joan Killeen" <Joan.Killeen@i...> on Thu, 14 Dec 2000 07:30:07 -0000
Hi,
First of all if you see the JSP code, you are invoking the method setHeig
ht
which should be SetHeight [Note the upper case in 's']
Next, There should be a directory called JoansBeans in classes directory 
=2E So
create a directory
D:\jakarta-tomcat\webapps\examples\web-inf\classes\JoansBeans . This dire
ctory
should contain the class file TestBean.class
If you do this it will compile without errors and execute successfully. B
etter
you bounce the server and execute the JSP script.
regards
parthasarathy 



"Joan Killeen" <Joan.Killeen@i...> wrote:
I cannot get a simple java bean to run under jakarta-tomcat.

Here is the bean:
*********************************************************************
package JoansBeans;
import java.beans.*;
public class TestBean 

{
	private int nHeight;
	public void SetHeight(int i)
	{
		nHeight =3D i;
	}
	public int getHeight()
	{
		return nHeight;
	}
}
*********************************************************************
I compile this bean and put the class file into WEB-INF/classes/JoansBean
s

Then I try to call it from the following JSP file:

********************************************************************
<jsp:useBean id=3D"firstBean" scope=3D"session" class=3D"JoansBeans.TestB
ean"/>
<jsp:setProperty name=3D"firstBean" property=3D"*"/>
<html>
<Body>
<%firstBean.setHeight(100);%>
<p>The height that was set is:</p>
<%=3D firstBean.getHeight() %>
</Body>
</HTML>
********************************************************************


The error I get is the following:
********************************************************************
org.apache.jasper.JasperException: Unable to compile class for
JSPD:\program files\Apache
Group\jakarta-tomcat\work\localhost_8080%2FFirstBean\_0002fCallBean_0002e
jspCallBean_jsp_0.java:58:
Class JoansBeans.TestBean not found.
                JoansBeans.TestBean firstBean =3D null;
                          ^
D:\program files\Apache
Group\jakarta-tomcat\work\localhost_8080%2FFirstBean\_0002fCallBean_0002e
jspCallBean_jsp_0.java:61:
Class JoansBeans.TestBean not found.
                    firstBean=3D (JoansBeans.TestBean)
                                          ^
D:\program files\Apache
Group\jakarta-tomcat\work\localhost_8080%2FFirstBean\_0002fCallBean_0002e
jspCallBean_jsp_0.java:66:
Class JoansBeans.TestBean not found.
                            firstBean =3D (JoansBeans.TestBean)
Beans.instantiate(getClassLoader(), "JoansBeans.TestBean");
                                                   ^
3 errors

	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:247)
	at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(Js
pServlet.java:149)

	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet
=2Ejava:161)

	at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:5
03)

	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559
)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Ht
tpConnectionHandler.java:160)

	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:
338)

	at java.lang.Thread.run(Unknown Source)


********************************************************************

Can anyone tell me what I am doing wrong????
Thanks for any hints.


--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to pro_jsp as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_jsp-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index