This is my jsp code which allow to select users through drop down list and then set respective user information to textbox after click on show button.
And i did any changes in shown text fields and click on update button to save those changes in to database(login table).
But how to update text field details through update button?
Here i also face another problem, while matching user_name in table with selected drop down list option e.g. I keep user name = sudhir pawar and any respected details in login table.
Then i select sudhir pawar from drop down list and click on show button no text fields with its respected details are shown in jsp page.
It work fine if i keep user name = sudhir only not sudhir pawar, so please give me solution for this situation.
you can create table using this query:-
CREATE TABLE "LOGIN"
( "NAME" VARCHAR2(50) NOT NULL ENABLE,
"USERNAME" VARCHAR2(50) NOT NULL ENABLE,
"PASSWORD" VARCHAR2(50) NOT NULL ENABLE,
"ADDRESS" VARCHAR2(200) NOT NULL ENABLE,
"CONTACT" NUMBER NOT NULL ENABLE,
"GENDER" VARCHAR2(10) NOT NULL ENABLE,
"EMAIL" VARCHAR2(50) NOT NULL ENABLE
Suggestion #1: Move most of this code into a java class.
Java code does not belong on a JSP.
SQL/Database code does not belong on a JSP.
You might consider methods in this java class such as
public List<String> getAllUserNames();
public User getUserBasedOnName(String name)
public void saveUserDetails(User user);
Suggestion#2: Break this JSP up.
This JSP seems to do many things.
- display a list of users to choose
- display the details for one user
- update the details for one user
I would suggest breaking this functionality up into seperate modules so that you can develop and test each independently.
>It work fine if i keep user name = sudhir only not sudhir pawar, so please give me solution for this situation.
Your database table has fields for both "name" and "username"
Currently your code appears to be looking up using the "name" column, rather than "username". That might explain this situation.