• Post Reply Bookmark Topic Watch Topic
  • New Topic

EmployeeID=(int)request.getParameter("EIN").trim(); code in servlet giving an error inconvertible tp

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

The below Code line is giving an error Inconvertible types: even after putting int in front of it

EmployeeID is an Int datatype variable and when parsing a string element to an Int its giving the error.Please let me know where I am going Wrong

EmployeeID=(int)request.getParameter("EIN").trim();
 
Louis Bros
Ranch Hand
Posts: 54
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at Integer and it's parseInt(String s) method.
 
Harsha Ka
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will work:

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
God I forgot parseInt() I will have to revise core java again
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!