• Post Reply 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

Reiterating tags

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bob Dunn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hold that thought. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic