Plain JSP and java:  can any one help .

I explained below the logic
each declaration & loop has comment
if possible please try it
After you run this code it will work fine as many as entris you want
Just make some changes remove comment marked with @ then run again the same program for more than 26 entries it will not work ..
I want this code to work for any no of entries user selected . minimum 30-35
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/Javascript" language="Javascript">
function goto()
  document.forms[0].submit();
</script>
</head>
<body>
<%
/* this block declares the array elements  for storing the values when page is submitted*/
     String len="";
    String arr_sr_no[]=null ;
     String arr_frmdeler_nm[]=null;
     String arr_frm_dest[]=null;
      String arr_todeler_nm[]=null;
      String arr_to_dest[]=null;
      String arr_mode_trans[]=null;
      String arr_fare[]=null;
   /* When page get submitted values are stored in theese array elements */  
      arr_sr_no=request.getParameterValues("sr_no");
      arr_frmdeler_nm=request.getParameterValues("frm_dlr_name");
      arr_frm_dest=request.getParameterValues("frm_dest");
      arr_todeler_nm=request.getParameterValues("to_dlr_name");
      arr_to_dest=request.getParameterValues("to_dest");
      // @ arr_mode_trans=request.getParameterValues("transport_mode");
      arr_fare=request.getParameterValues("fare");
   /* Array of serial number is null for first time when page gets loaded so i initialized
     the len="1";
    if(arr_sr_no==null)
           len="1";          
  /* when array of serial  is not null when page gets loaded
     i initialized len with the length of the array of serial number i.e arr_sr_no[]
        if(arr_sr_no!=null)
           int i = arr_sr_no.length;
           len = Integer.toString(i);
        // Converted String  len into Integer
         int add_cnt = Integer.parseInt(len);
       /* this line gets the value from Select combo which select  no. of rows  to be generated
        for table entries */
        String str2=request.getParameter("no_statements");
        String str3="";
      //when  str2 is not null initialize the str3 with str2.
      // This is for that how many rows we have selected in  <select> tag
      //else part is for first time when page is loaded
      // so that one row will be defaultly created
       if(str2!=null)
          str3=str2;
        else
          str3="1";
      //converted String to integer..
         int entry=Integer.parseInt(str3);
%>
<form name="myform" >
<table width="500" border="1" >
    <tr>
       <%--This is Select tag which Selects the No of Rows whch onChange calls goto()
           and page gets submitted
       --%>
           <select  name="no_statements" onChange="goto()">
                  <%
                      int cnt;
                     for( cnt=1;cnt<=30;cnt++)
                  %>
                      <option value="<%=cnt%>" <% if(entry==cnt) out.println("selected");%>> <%=cnt%> </option>
                  <%
                  %>
                  </select>   
           </td>
<%
  /*  This for loop gets the iterates for Selected no of Rows in <SELECT> tag
   "entry" variable is initialized above for selected rows
       for (int i=1;i<=entry;i++)
              String strdlr_name="";
              String strfrm_dest="";
              String strtodeler_nm="";
              String strto_dest="";
               String trans_mode="0";
                String strfare="";
        /* This condition checks for any array is not null*/
        if(arr_sr_no!=null)
                /* this array checks for each time that i is less than add_cnt
                   where add_cnt is length of arr_sr_no[] (which is in turn length
                   of each array we have stored above)
                   This cond'n ensures that no null pointer assignment is done
                if(i<=add_cnt)
                   /* we initializes each element of each array serially to
                    local String variables */
                   strdlr_name=arr_frmdeler_nm[i-1];
                   strfrm_dest= arr_frm_dest[i-1];
                   strtodeler_nm= arr_todeler_nm[i-1];
                   strto_dest= arr_to_dest[i-1];
                   // @ trans_mode=arr_mode_trans[i-1];
                    strfare =arr_fare[i-1];
                  }// end of inner if
              }// end of outer if
        %>
     <tr>
            <%-- here we assign local string  values to <input> box this will
                 this will ensure that all entris  will stay intact when page
                  gets submitted
            --%>
            <td><input name="sr_no" type="text" value="<%=i%>" size="2"></td>
            <td><input name="frm_dlr_name" type="text" value="<%=strdlr_name%>" size="16"></td>
            <td><input name="frm_dest" type="text" value="<%=strfrm_dest%>" size="11"></td>
            <td><input name="to_dlr_name" type="text" value="<%=strtodeler_nm%>" size="18"></td>
            <td><input name="to_dest" type="text" value="<%=strto_dest%>" size="11"></td>
           <%-- @ <td><select name="transport_mode" >
                    <option value="0" <%if("0".equals(trans_mode)) out.println("selected"); %>>--Select--</option>
                    <option value="1" <%if("1".equals(trans_mode)) out.println("selected"); %>>Air</option>
                    <option value="2" <%if("2".equals(trans_mode) )out.println("selected"); %>>Train</option>
                    <option value="3" <%if("3".equals(trans_mode)) out.println("selected"); %>>Bus</option>
                    <option value="4" <%if("4".equals(trans_mode)) out.println("selected"); %>>Taxi</option>
                    <option value="5" <%if("5".equals(trans_mode)) out.println("selected"); %>>Two Wheeler</option>
                    <option value="6" <%if("6".equals(trans_mode)) out.println("selected"); %>>Auto Rikshaw</option>
                 </select>
          --%>
       <td><input name="fare" type="text" value="<%=strfare%>" size="4"></td>
       </tr>
        <%
        }// End of For loop
        %>
</table>
</form>
</body>
</html>Hope you will reply
it is very urgent

No need to post it again. Particularly when it is right near the top.
http://forum.java.sun.com/thread.jspa?threadID=765816&tstart=0

Similar Messages

Maybe you are looking for

  • I need help with my setup Please !!! 2800+ athlon xp

    hi all .......... great forum here.....!!! I am having probs with my new setup and I am at a wits end of what to do so i'll explain my problem. I have just bought a AMD athlon 2800+ cpu for my mobo (KT3 ultra 6830e v.1.0) and I am unable to run the c

  • Transfer of Itunes Library to Vista

    I have a single PC running Media Center Edition with an 80Gb hard drive. I bought a new 750Gb drive and decided to install Vista on it. Both drives are installed and I can boot to Vista by swapping the SATA drive cable. I have installed Itunes under

  • AVCHD (1080i) to DVD

    Hi friends! I´ve record with Sony cameras a wedding.The file format was AVCHD 1080i. I need to deliver to the client a Bluray and a DVD with the same content. Using the Premiere and Encore Cs6 the Bluray has a very good quality. I have edit in Premie

  • Customer Statements F.27 by email

    Hi all: I want to send custom statements by email using F.27 Do I use BTE 2310? I have already mapped it in FIBF using the sample code in include LXFKOF01 I have put a breakpoint in the BTE however its not stopping. what else am i missing? please hel

  • Hidden/Missing Text - Acrobat Pro

    I have Acrobat 9 Pro for my Mac. I created a PDF from a blank page. My document has an opening paragraph, and then a list of 100 + names. While I see my PDF is three pages long, the two and a half pages with the names are blank. Is this part of Metad