assign Database values to textbox rows on form

assign Database values to textbox rows on form

I am trying to get the database values saved from form into Textbox in same form. The values are loaded whenever the form is loaded. I have written a example code what I am doing below. I have 5 rows of textboxes. I have written the below code that get the values from database. But my knowledge is limited about getting those five rows of values to the five rows of textboxes either using JSP or JAVAScript. Tried searching online but didn't fine related answer. Any help will be appreciated. Thank you.

Firstly, you should not be putting Java code into a JSP.

You database fetch should be preformed in a mode-layer class that copies the data into a List of beans or other construct, and immediately closes the resultset. The servlet controller for the page calls this call and passes the list to the JSP as a scoped variable. The JSP uses <c:forEach> to iterate over the list and create the corresponding HTML output.

ou can't iterate over data using just HTML. For that you'll need to use JSP. And you should be using JSTL and EL, and not obsolete scriptlets.

I never used JSTL or AJAX. I googled and tried using <C:out> to print the value. But It looks like I am making many mistakes with syntax and logic. Is it possible to give a small example using JSTL so that I can print the value. Thank u. Also Tried below code that didn't work.

 

view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped

    String NA_ProcID = null; 
    String NA_Row_Id= null; 
    String NA_SourceIP = null; 
    String empId = "SELECT [NA_ProcID], [NA_Row_Id], [NA_SourceIP] FROM [Miscellaneous].[dbo].[NETWORK_ACCESS] where NA_ProcID = ? "; 
    PreparedStatement prpStatement66 = conn.prepareStatement(empId); 
    prpStatement66.setString(1, ProcID); 
    ResultSet rs66 = prpStatement66.executeQuery(); 
    while (rs66.next()) { 
        NA_ProcID = rs66.getString(1);  //add remaining values from DESC Table. 
        NA_Row_Id = rs66.getString(2); 
        NA_SourceIP = rs66.getString(3); 
        out.println(NA_ProcID); 
    } 
    %> 
    <body> 
    <input type="text"  value="<%=NA_Row_Id %>" name="na" > 
    <input type="text"  value="<%=NA_Row_Id %>" name="na" > 

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright