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 get a simple bean example to work using Tomcat and jsp

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Looks like you have spelt "linebean" differently in the useBean tag andthe class name.
~Anoop
 
Ray Smilgius
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I corrected this, but I still have the same problem with not finding the class
Thanks Ray
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is probably a better fit for our new Tomcat forum, so I'm moving it there in hopes you will get more reponses.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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).]
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic