java - Pass ArrayList to servlet? -


how pass data arraylist servlet?

<table id="table1">      <tr>           <td>               <input type="hidden" value="test1_1" name="name1_1" />           </td>          <td>_               <input type="hidden" value="test2_1" name="name2_" />           </td>          <td>               <input type="hidden" value="test3_1" name="name3_1" />           </td>      </tr>      <tr>           <td>               <input type="hidden" value="test1_2" name="name1_2" />           </td>          <td>               <input type="hidden" value="test2_2" name="name2_2" />           </td>          <td>               <input type="hidden" value="test3_2" name="name3_2" />           </td>      </tr>      <tr>           <td>               <input type="hidden" value="test1_3" name="name1_3" />           </td>          <td>               <input type="hidden" value="test2_3" name="name2_3" />           </td>          <td>               <input type="hidden" value="test3_3" name="name3_3" />           </td>      </tr> </table>     list<model> newlist = new arraylist<model>(); 

the servlet newlist must contains 3 model

model1 value of [getsomething1 = test1_1, getsomething2 = test2_1, getsomething3 = test3_1] model2 value of [getsomething1 = test1_2, getsomething2 = test2_2, getsomething3 = test3_2] model3 value of [getsomething1 = test1_3, getsomething3 = test2_3, getsomething3 = test3_3] 

and not limit 3 model in list depends on number of row.

it create number of models based on number of row in jsp.

you can't pass arraylist, can read string[] if give inputs want in array same name.

 <input name='test' />  <input name='test' />  <input name='test' /> 

in servlet, use request.getparametervalues(name) (which returns string[]) rather request.getparameter(name) returns 1 value.

 string[] testvalues = request.getparametervalues("test"); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -