[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3283
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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