I'm passing some arrays (created by checkboxes) between servlets and
JSPs. The code works, but it just doesn't look right. I'm worried
that I will run into some memory problems at some later point.
Here is what I'm doing: The servlet InitVisit initializes an array
(all checkboxes unchecked) and forwards it to a JSP
String ordered[] = {"",""}; // I actually have 11 checkboxes !!!
request.setAttr ibute("ORDERED" ,ordered};
visit.jsp receives this array:
<% String ordered[] = {"",""}; %>
<% ordered = (String[])request.getAtt ribute("ORDERED ); %>
visit.jsp then displays a sequence of checkboxes (i = 0,...10):
<input type=checkbox name="ORDERED" value=i>
or
<input type=checkbox checked name="ORDERED" value=i>
(but at this point all checkboxes are unchecked)
The user selects any number of checkboxes (up to 11) and posts to a
servlet visitUpdate.
visitUpdate allocates memory again:
String ordered[] = new String[12];
ordered = request.getPara meterValues("OR DERED");
After processing the data, visitUpdate forwards its request back to
the same old JSP visit.jsp. So, again we have
<% String ordered[] = {"",""}; %>
<% ordered = (String[])request.getAtt ribute("ORDERED ); %>
visit.jsp displays a sequence of checkboxes (i = 0,...10):
<input type=checkbox name="ORDERED" value=i>
or
<input type=checkbox checked name="ORDERED" value=i>
(At this point the ORDERED attribute might have an array of size 11 if
all checkboxes had been checked previously)
The code works, but somehow it doesn't look right. in visit.jsp I
allocate an array of size 2 and populate with 0 to 11 elements. Then,
in visitUpdate I do just the opposite and allocate an array of size 12
to populate with 0 - 11 elements: What do the commands
request.getPara meterValues and request.getAttr ibute do with my memory
allocations?
Anke
JSPs. The code works, but it just doesn't look right. I'm worried
that I will run into some memory problems at some later point.
Here is what I'm doing: The servlet InitVisit initializes an array
(all checkboxes unchecked) and forwards it to a JSP
String ordered[] = {"",""}; // I actually have 11 checkboxes !!!
request.setAttr ibute("ORDERED" ,ordered};
visit.jsp receives this array:
<% String ordered[] = {"",""}; %>
<% ordered = (String[])request.getAtt ribute("ORDERED ); %>
visit.jsp then displays a sequence of checkboxes (i = 0,...10):
<input type=checkbox name="ORDERED" value=i>
or
<input type=checkbox checked name="ORDERED" value=i>
(but at this point all checkboxes are unchecked)
The user selects any number of checkboxes (up to 11) and posts to a
servlet visitUpdate.
visitUpdate allocates memory again:
String ordered[] = new String[12];
ordered = request.getPara meterValues("OR DERED");
After processing the data, visitUpdate forwards its request back to
the same old JSP visit.jsp. So, again we have
<% String ordered[] = {"",""}; %>
<% ordered = (String[])request.getAtt ribute("ORDERED ); %>
visit.jsp displays a sequence of checkboxes (i = 0,...10):
<input type=checkbox name="ORDERED" value=i>
or
<input type=checkbox checked name="ORDERED" value=i>
(At this point the ORDERED attribute might have an array of size 11 if
all checkboxes had been checked previously)
The code works, but somehow it doesn't look right. in visit.jsp I
allocate an array of size 2 and populate with 0 to 11 elements. Then,
in visitUpdate I do just the opposite and allocate an array of size 12
to populate with 0 - 11 elements: What do the commands
request.getPara meterValues and request.getAttr ibute do with my memory
allocations?
Anke
Comment