0

My controller.java encounter an input string: "undefined".
Please help.

public ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

   int rowsPerPage = 20;
   String rowsPerPageStr = request.getParameter("rowsPerPage");
   logger.info("rowsPerPageStr " + rowsPerPageStr);
   if (rowsPerPageStr != null) {
	rowsPerPage = Integer.parseInt(rowsPerPageStr);
   }

My jsp page use javascript as follows:

window.location = "hwdisplay?rowsPerPage=" + rowsPerPage;

Eclipse Console output is:
rowsPerPageStr undefined
Servlet.service() for servlet hwmgr threw exception java.lang.NumberFormatException: For input string: "undefined"

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by javaAddict
0

The NumberFormatException tells you that what you used as argument is not a number. It also says that the value you passed is the String: undefined

threw exception java.lang.NumberFormatException: For input string: "undefined"

That would mean that the value of rowsPerPageStr is the String: "undefined": String rowsPerPageStr = request.getParameter("rowsPerPage"); So here:

window.location = "hwdisplay?rowsPerPage=" + rowsPerPage;

The variable rowsPerPage has the value: "undefined"

Try putting some alerts and see what you pass as parameter:

alert(rowsPerPage);
window.location = "hwdisplay?rowsPerPage=" + rowsPerPage;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.