• Post Reply Bookmark Topic Watch Topic
  • New Topic

assign Database values to textbox rows on form

 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.





 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply. As I mentioned, it is an example code and not full code. If you help me with above code, then I can do the remaining code. I am using HTML to display the text values in textbox and not JSP tags. In this case, How I will I be able to Iterate?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Another approach is to fetch the data with Ajax and iterate over it with JavaScript, but I don't think that's what you are asking.)
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!