servlet: error trying to convert string to int. throws NumberFormatException: For input String: "2/"

StackOverflow https://stackoverflow.com/questions/21276393

  •  01-10-2022
  •  | 
  •  

Question

my code in servlet is:

int gid = Integer.parseInt(request.getParameter("deleteid"));

where deleteid is hidden form field in jsp. The glassfish server log states that, java.lang.NumberFormatException: For input string: "2/"

Was it helpful?

Solution

As its appending "/" after number I just used following method to solve the problem. Sorry for asking it at the first place:

int gid = Integer.parseInt(request.getParameter("deleteid").replaceAll("/"));

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top