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
Solved

creating table rows dynamically in servlet

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.

860 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