• Post Reply Bookmark Topic Watch Topic
  • New Topic

Report  RSS feed

 
kokila devi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

how to create dynamic table with cell border from mvc controller, please help me to solve this problem its very urgent.








 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In MVC controller, declare a method which returns the object filled in ArrayList.
foward the ArrayList thru request dispatcher in servlet.

and in jsp make one loop which will run till the size of ArrayList.

E.g.

1. Signature of method in Model class.(Assuming the class name student)
public ArrayList<Student> getData(int std_id)
{
//Business logic...
}
2. Call from servlet
MyModel m=new MyModel();
ArrayList<Student> arr=new ArrayList<Student>();

arr=m.getData(10);

request.setAttribute("arr",arr);
RequestDispatcher rd=request.getRequestDispatcher("new.jsp");
request.forward(request,response);

3. In new.jsp
ArrayList<Student> arr=new ArrayList<Student>();
arr=request.getAttribute("arr");
Student s;
int i=arr.size();

for(int j=0;j<i;j++)
{
s=new Student();
s=arr.get(j);
//SOme code..
}


dont forget to use scriplets.and necessary import statement.

javascript:emoticon('');
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sorry I forgot to mention table tag...

<table>
write for loop here and use <tr><td> tags...
</table>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!