File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Hashtable method arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hashtable method arguments" Watch "Hashtable method arguments" New topic
Author

Hashtable method arguments

sumit sharmast
Greenhorn

Joined: Jul 29, 2012
Posts: 15
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:


Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3934
    
  17

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.


Steve
sumit sharmast
Greenhorn

Joined: Jul 29, 2012
Posts: 15
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

Joined: Jan 28, 2003
Posts: 3934
    
  17

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hashtable method arguments
 
Similar Threads
Add Update problem in Hashtable
shopping cart prob
static utility class from servlet
Hashtable
Storing of Data