• 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

Hashtable method arguments

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am getting the following error in the SERVLET CODE. Please help.

ERROR MESSAGE:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.Error: Unresolved compilation problems:
The method addItem(String, LineItem) in the type Cart is not applicable for the arguments (LineItem)
The method removeItem(String, LineItem) in the type Cart is not applicable for the arguments (LineItem)

music.cart.DisplayCartServlet.doPost(DisplayCartServlet.java:87)
music.cart.DisplayCartServlet.doGet(DisplayCartServlet.java:114)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.

Apache Tomcat/6.0.20
--------------------------------------------------------------------------------

LineItem.Java Code




Cart.Java Code


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SERVLET CODE:


-----------------------------------------------------------------------------------


JDBC CODE:


 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message tells you:

The method addItem(String, LineItem) in the type Cart is not applicable for the arguments (LineItem)
The method removeItem(String, LineItem) in the type Cart is not applicable for the arguments (LineItem)


You are calling it like cart.addItem(LineItem) and cart.removeItem(LineItem), and you should be calling them like cart.addItem(String, LineItem), and cart.removeItem(String, LineItem). Each of those methods requires a String parameter which you need to provide. Figure out what that String parameter is supposed to be and provide a valid String along with the LineItem.
 
sumit sharmast
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Mr. Steve,

Thank you for your reply. What will be the correct argument inside the addItem method in the Servlet code, in place of addItem(t) ???

Can you correct it please. I would be very thankful.

Regards,

Sumit.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You wrote the cart code did you not? That String must mean something, and you must have had a reason for it when you wrote the code. Perhaps if you wrote a comment about what it is supposed to mean, then we could figure that out. From what little I know:
1) There is a required String
2) That String is used as a Key in a Hashtable
3) That String is named 'id' in the method signature.

So I guess the String should be some identifier that can be used to store and retrieve the LineItem. But how you are supposed to get / make one goes beyond my ability to read your past-mind.
 
reply
    Bookmark Topic Watch Topic
  • New Topic