• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3570
  • Last Modified:

Type mismatch: cannot convert from Integer to int

I got this error. I have checked my code. I cannot find the result. Please help~~!!!

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 86 in the jsp file: /submit.jsp
Generated servlet error:
Type mismatch: cannot convert from Integer to int

An error occurred at line: 86 in the jsp file: /submit.jsp
Generated servlet error:
The method get(Object) in the type HashMap is not applicable for the arguments (int)

An error occurred at line: 86 in the jsp file: /submit.jsp
Generated servlet error:
The method get(Object) in the type HashMap is not applicable for the arguments (int)


      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

0
a122178
Asked:
a122178
  • 3
  • 3
1 Solution
 
objectsCommented:
looks like you are trying to us an int as a key into a HashMap. You cannot use primitives for that, you need to use an Object (such as an Integer to wrap your int)
whats your page look like?
0
 
a122178Author Commented:
item.put(_item.getDblProductID(), _item)
 if _item.getDblProductID() is an integer, is it possible to do this way?

Thank you so much
0
 
objectsCommented:
you would need to use:

item.put(new Integer(_item.getDblProductID()), _item);
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
a122178Author Commented:
How about if I want to get from an int?

item.get(new Integer( int) ) , is that right?
0
 
objectsCommented:
correct
0
 
a122178Author Commented:
It still comes out even I change. After I refresh the screen it works.
Why?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now