Solved

creating table rows dynamically in servlet

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
python question 5 57
groovy example issue 10 66
advertisement module in core php 4 87
How can i compile this github project?? 2 41
A short article about problems I had with the new location API and permissions in Marshmallow
This is about my first experience with programming Arduino.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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 …

708 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

15 Experts available now in Live!

Get 1:1 Help Now