HTML input form elements all have a value attribute.
So when the select box changes and you get the data from the database use the value attribute to populate form elements. This can be done with a standard/typical POST/GET refreshing the page with the new values. So you might have something like:
or this could be done using AJAX. As you are new to all this I'd get the basics down first though. Once you understand it then you can look at helpful technologies such as AJAX to make things better on your applications.
See the JSP FAQ to make sure that your web app is set up correctly for JSP 2.0.
Joined: Nov 08, 2008
Originally posted by Bosun Bello: ....., fire of a call to the servlet/backend that will get the associated values and store it in the appropriate scope so that the view/jsp can get it from there.
I had to change the idea to the following there is a single page. At the top of the page there is a textbox and a search button. followed by a few fields (text boxes) to enter or update data.
now if the user enters a username in the first text box, which is the "search text box" and clicks the search button i get the data from the database in a servlet. after that it should redirect the admin to the same page but now with the fields below the search textbox prefilled with the data fetched from the database.
I have the following code:
my "suser" servlet fetches the data from the database and i have written another class/bean "User" that stores the data fetched, which is instanciated in the servlet. Now i would like get the data from that bean to prefill the forms.