I am a beginner using JSP. I want to display a list of incrementing integers using a maximum range of the users choice.
Entering: 6 should display the following:
input.jsp
<body>
<input type="number" name="numberMax" required>
<input type="submit" value="submit">
</body>
jspResult.jsp
<body>
<%
int numberMax = request.getParameter("numberMax"); // Cannot convert from String to int
%>
for (int i = 1; i <= numberMax; i++)
{ %>
<ul>
<li><%= i %></li>
</ul>
<% } %>
</body>
How can I convert the input to an integer in order for the jsp scriptlet to print.
Try using this:
<%int no = Integer.parseInt(request.getParameter("numberMax"));%>
Its working for me.