Solved

creating table rows dynamically in servlet

Posted on 2004-09-03
3
1,303 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now