Solved

creating table rows dynamically in servlet

Posted on 2004-09-03
3
1,315 Views
Last Modified: 2013-11-24
Dear All,
   I am in need of answer for this query very urgently.

      The user will give me the input for no of uploads for example 23. Based on the input i have to create table rows each page should contain 10 rows each. So if the input is 23 then i have to show 3 pages having 10 rows each in first two page and 3 rows in third page. The first page should contain a navigation button to go the second page and in the same for the second page for third page and so on based on the input value.

  I have to do this using servlet ........

  kindly help me as early as possible.

   
0
Comment
Question by:priyashree
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
mlpk_tyr earned 75 total points
ID: 11988903
hi,
i give you a hint and develop this with syntactical changes

int totalRec = request.getParameter("totalrecords"); // maximum no of records  your case 23
int currindex=request.getParameter("currindex");   // the  page list number  requested
int temp=( (totalRec/10) *10) ;
if(  temp != totRec)
      int totpages=  temp+1;
else{
       int totpages=  temp;
}
int startlist = 1+ ( (currindex-1)*10 );    // if  requested page number is 2  then starting number is 11
if( totalRec-startlist > 9 )    {                     // if we have 16 records thenending number is 16
         int endlist= 1+ ( (currindex)*10 )       // this is 16 else it will be 20
}else{
         int endlist= totalRec;
}

for(int i=startlist;i<endlist; i++){
out.writeln("<html>");
out.writeln("<form>");
out.writeln("<table>");
if(totalRec>0){
out.writeln("<tr><td> ");
out.writeln("input type='select' name=' currindex' ")
for(int i=1;i<totpages;i++)  out.writeln("<options value='"+ i + "' >"+ i + " </option>")
out.writeln("</td></tr>");
}

for(int j=1 ;j<10 ;j++){
out.writeln("<tr><td>);
out.witeln("<input type='text' name ='t1"+ j +"'  value>")  //put whatever element you want to have for  each row, make sure that you create an array of elements
out.writeln("</td></tr>);
}
out.writeln("</table>");
}
out.writeln("input type='submit'>");

out.writeln("</form>");
out.writeln("</html>");
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to implement Singleton Design Pattern in Java.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question