I have two problems,
First:
Form
<FORM ACTION="create" METHOD="POST">
<fieldset>
<INPUT TYPE="TEXT" NAME="paraile">
<input type="submit" name="Submit" class="button" value="Gen" />
</fieldset>
</FORM>
servlet method doPost
String ankieta = "WEB-INF/ankieta.jsp";
int ile = Integer.parseInt(request.getParameter("paraile"));
request.setAttribute("ile", ile);
request.getRequestDispatcher(ankieta).forward(request, response);
ankieta.jsp
<%
int a= Integer.parseInt(request.getParameter("ile"));
for (int i = 0; i < a; i++) {
%>
Number: <%=i%>
<%
}
%>
This simple excercise doesn't work. Really, I need loop to create a couple textbox to voting.
and my second question. When I have a few dynamic textbox, and I need their value in servlet. Can I combine them to string in jsp file and then send one parameter to servlet?
edit: It's working, but still this is badly solution. Thank You Luiggi!
<FORM ACTION="create" METHOD="POST">
<fieldset>
<legend>Vote</legend>
<%
String string = (String) request.getAttribute("ile");
int a= Integer.parseInt(string);
for (int i=1; i <= a; ++i) {
%>
<label>Option <%=i%></label>
<INPUT TYPE="TEXT" NAME="option<%=i%>">
<%
}
%>
<input type="submit" name="Submit" class="button" value="Accept" />
</fieldset>