I am getting values from user using a html file which is then used by the servlet to perform certain calculations.And when i execute my web application in the browser it takes values from user but when i click the submit button after getting values,this error is thrown. "HTTP ERROR 500 Problem accessing /servlet/MvcServlet. Reason: java.lang.Integer cannot be cast to java.lang.String"
My servlet code is like this:
int gpa=total/c;
req.setAttribute("gpa",gpa);
RequestDispatcher view = req.getRequestDispatcher("/result.jsp");
view.forward(req, resp); `
and my jsp code is:
String gpa = (String) request.getAttribute("gpa");
int r=Integer.parseInt(gpa);
out.println("Your Result is "+ r);
Please help me out for passing my integer value "gpa" in servlet to jsp.