aspose file tools*
The moose likes Tomcat and the fly likes trying to get a simple bean example to work using Tomcat and jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Reply locked New topic
Author

trying to get a simple bean example to work using Tomcat and jsp

Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
Here is the code for the jsp:
<html>
<head>
<jsp:useBean class="linebean" id="bean0" scope="page" />
<title>Access JavaBean Methods</title>
</head>
<body>
Welcome to my Web page
<%= bean0.stars(30) %>
</body>
</html>

/////////////////////here is the code for the bean
public class linebean
{
public String stars(int x)
{
String text = "<br>";
for(int i =0;i<x;i++)
text = text + "*";
return text + "<br>";
}

public String doubleLine(int x)
{
String text = "<br>";
for (int i=0;i<x;i++)
text = text + "=";
return text + "<br>";
}
}
////It is in the C:\jakarta-tomcat-4.0\webapps\examples\WEB-INF\classes where I put all my servlet classes to run
I am getting the error linebean not found in my JSP a servlet exception
also does a bean have to be in a package???mine is not.
Thanks Ray Smilgius
[This message has been edited by Ray Smilgius (edited November 16, 2001).]
[This message has been edited by Ray Smilgius (edited November 16, 2001).]


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
Nair Anoop
Ranch Hand

Joined: May 09, 2001
Posts: 68
Looks like you have spelt "linebean" differently in the useBean tag andthe class name.
~Anoop
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
I corrected this, but I still have the same problem with not finding the class
Thanks Ray
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
This is probably a better fit for our new Tomcat forum, so I'm moving it there in hopes you will get more reponses.


"I'm not back." - Bill Harding, Twister
Sagar Bilgi
Ranch Hand

Joined: Apr 26, 2001
Posts: 37
Hi,
I was just trying to see if I got the same error that you are getting and yes I do. It seems that the compiled servlet is by default put in the package org.apache.jsp; and it looks for the linebean in that package. Could that be the problem? when you look at the servlet in C:\tomcat\work\localhost\project ( my work is done in a project directory hence the project in the URL)
Also a couple of other questions in addition to the ones above. If you write a jsp and put it in some directory under webapps..where should the class files that the jsp uses reside..should they be under WEB-INF/classes or should they be in the root of the directory under webapps in my case webapps\project.
Any input would be greatly appreciated.
Thanks
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120

C:\jakarta-tomcat-4.0\webapps\FortKnox
under FortKnox I have my jsp's like index.jsp etc...
I am posting another problem with finding the servlet see my above post then I will try to resolve the linebean issue.
baby steps we go....
------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
Donald Nunn
Ranch Hand

Joined: Nov 11, 2000
Posts: 200
Hello, Ray. I'm having the same problem. I installed Tomcat 4.0 and for some reason it can't find the class file. The first statement is what is creating the problem and the source file compiled properly.
<jsp:useBean id="orderedFruit" class="Fruit" /> This one!
<jsp:setProperty name="orderedFruit" property="fruitName" value="Mango" />
<jsp:setProperty name="orderedFruit" property="color" value="Orange" />
<jsp:setProperty name="orderedFruit" property="price" value="5.95" />
<jsp:setProperty name="orderedFruit" property="quantityInPounds" param="quantity" />
<HTML>
<body>
<h1>Your Fruit Order</h1>
<br><br>
Fruit: <jsp:getProperty name="orderedFruit" property="fruitName"/><br>
Color: <jsp:getProperty name="orderedFruit" property="color" /><br>
Price: $<jsp:getProperty name="orderedFruit" property="price" /><br>
Quantity: <jsp:getProperty name="orderedFruit" property="quantityInPounds" /><br>
Total: $<%=orderedFruit.getPrice()*orderedFruit.getQuantityInPounds() %>
<p></p>
<a href="FruitOrder.html">Return to order form to adjust quantity</a>
</body>
</html>
Thanks,


------------------
Donald Nunn
Sun Certified Programmer for the Java� 2 Platform


<b>Donald Nunn</b><br />Sun Certified Programmer for the Java 2 Platform
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Is the Fruit class part of a package?

I'm also closing this, as I see you've started a new topic.
[This message has been edited by Mike Curwen (edited November 28, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trying to get a simple bean example to work using Tomcat and jsp