java - Pass class instance from jsp to servlet -


hi need show list of "categories" on jsp page db , user should able remove row.

  1. i've created category class.
  2. to able pass list of cetogories jsp i've created "categorylistbean":

    public class categorylistbean {   private list<category> categories;   public list<category> getcategories() {     return categories;   }   public void setcategories(list<category> categories) {     this.categories = categories;   } } 

and in jsp:

    <jsp:usebean id="listcategory" class="beans.categorylistbean" scope="request"/>     ...     <c:foreach items="${listcategory.categories}" var="item">       <tr>         <td>${item.name}</td>         <td>${item.description}</td>         <td>           <form action="removecategory" method="post">             <input type="submit" value="remove">           </form>         </td>       </tr>     </c:foreach> 

how can "removecategory" servlet understand item user want deleted? yes, can pass parameter "itemid = item.id" i'm using hibernate comunicate db , think, need instance of "category" class write this:

(hibernate) session.begintransaction(); (hibernate) session.delete(categoryinstance); (hibernate) session.gettransaction().commit(); 

can use

    <input type="hidden" name="item" value=${item}> 

in jsp form that? , if can, how can parameter in servlet?

thanks


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -