java - Pass class instance from jsp to servlet -
hi need show list of "categories" on jsp page db , user should able remove row.
- i've created category class.
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
Post a Comment