| Author |
Reiterating tags
|
Bob Dunn
Greenhorn
Joined: Jun 23, 2011
Posts: 12
|
|
I'm trying to create a new tag class to display an array list. There is an error on line lineItems = product.getProduct(); Any help would be great..
ProductsTags.java
ProductsServlet
products.java
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
I'm guessing here, since you didn't tell us what the error was (that would have been a big help, since the error message tells you exactly what is wrong).
Where is the getProduct() method defined?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Bob Dunn
Greenhorn
Joined: Jun 23, 2011
Posts: 12
|
|
|
I think that's the problem. The getProduct isn't defined. I'm not sure what this should be but it should be referencing the arraylist in the ProductsServlet.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
you're not sure what WHAT should be?
getProduct() is a method. since you are assigning what it returns to a LineItem, the method has to return one of those.
|
 |
Bob Dunn
Greenhorn
Joined: Jun 23, 2011
Posts: 12
|
|
|
In the products servlet, it loads an array list of products objects. In the tag, i want to read this array list. the getProduct method isn't defined anywhere so it's not correct. I had it as getProducts but it didn't work either. I thought it would correspond to the ArrayList line in the products servlet which has getProducts. i have a disconnect somewhere. Thanks in advance for any help.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
You can't call a method that doesn't exist.
You have created a class called "Products" - therefore, you control what methods exist and what don't for the Products class.
So, I see two options:
1) don't call the getProducts() method, since it doesn't exist.
2) Write a method in your Products class call "getProducts" (or getProduct, if that's what you need) and make it do what you want.
I am not a servlet guy, so I can't address that part.
What exactly do you expect the method getProducts to do? What should it return?
|
 |
Bob Dunn
Greenhorn
Joined: Jun 23, 2011
Posts: 12
|
|
|
It should return the objects in the arraylist that is stored as an attribute of the session object in the ProductsServlet class.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
Bob Dunn wrote:It should return the objects in the arraylist that is stored as an attribute of the session object in the ProductsServlet class.
so, write it and make it do that.
|
 |
Bob Dunn
Greenhorn
Joined: Jun 23, 2011
Posts: 12
|
|
|
Well... if i knew how to do that I wouldn't be asking and obviously you don't know how to either or else your answer would have been more appropriate. Thanks for wasting my time and providing no assistance.
|
 |
 |
|
|
subject: Reiterating tags
|
|
|