Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

vector problem,how to retrieve data stored in vector and display in jsp pag

 
saswat rashmi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone

i ma getting problem in vector. i hve on ejsp page ,in which i am using vector ,to store the data from databse ,but i dont knwo how to retrive the values store in vector ,so that i can display all records in jsp page

please help


please tell me where i am wrong .i want to dipaly the value from databse which i have stored in vector,but i dont knwo how to get values form vector one by one qand dispaly
[ October 24, 2007: Message edited by: Ben Souther ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

it more like bad practice if you do data manupulation in your jsp, as jsp only use for view, I like to refer to you "Simple MVC" by ben souther, http://faq.javaranch.com/java/CodeBarnServlets

hope it helps.
 
shankar reddy
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You are storing the values in the vector, by using while loop. Now the data is readily available in the Vector. You can use Enumarator to get the elements.

for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
System.out.println(e.nextElement());
}
 
shankar reddy
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You are storing the values in the vector, by using while loop. Now the data is readily available in the Vector. You can use Enumarator to get the elements.

for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
System.out.println(e.nextElement());
}
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should move away from scripting on the JSP so getting a Enumeration from the vector and looping in the JSP is still a bad idea. Look into JSTL tag c:forEach to do this.

Also
Vector VOUCHER_ID;

Why are you using capital letters for your variable names? This convention is for static final variables (constants).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic