Bonjour,
quelqu'un peut-il m'aider a me montrer comment extraire de l'information de ma bean et puis l'afficher sur ma page .jsp?
merci
voici le bout de ma page .jsp
voici ma class bean:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <% BeanEmployee bean = new BeanEmployee(); findEmployeeId emp = new findEmployeeId(); bean = emp.findEmoloyeeId(request.getAttribute("employeeid"); %>
et voici ma methode qui alimente la Bean pour etre utilisé plus tard au niveau de la page web.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 package DBconnect; public class BeanEmployee { private int employeeid; private String username; private String password; private String team; private String firstname; private String lastname; private String email; private String telephone; private boolean supervisor; private boolean admin; public BeanEmployee() { employeeid = 0; username = null; password = null; team = null; firstname = null; lastname = null; email = null; telephone = null; supervisor = false; admin = false; } public int getEmployeeid() { return employeeid; } public void setEmployeeid(int employeeid) { this.employeeid = employeeid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getTeam() { return team; } public void setTeam(String team) { this.team = team; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public boolean isSupervisor() { return supervisor; } public void setSupervisor(boolean supervisor) { this.supervisor = supervisor; } public boolean isAdmin() { return admin; } public void setAdmin(boolean admin) { this.admin = admin; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 package DBconnect; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class findEmployeeId { public BeanEmployee findEmoloyeeId(int emplId) { BeanEmployee bEmployee = new BeanEmployee(); try { Connect co = new Connect(); Connection conn = Connect.ConnectDB(); Statement st = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rec; rec = st.executeQuery("SELECT EmployeeID, UserName, Password, Team, FirstName, LastName, Email, Tel, Supervisor, Admin " + " FROM Users Where EmployeeID = " + emplId + ";"); //rec.first(); //System.out.println(rec.getInt("EmployeeID")+ "\n" + rec.getString("FirstName")+ "\n" + rec.getString("LastName") ); // int ee = rec.getRow(); while (rec.next()) { //be.setEmployeeid(new Integer(rec.getInt("EmployeeID"))); bEmployee.setEmployeeid(rec.getInt("EmployeeID")); bEmployee.setUsername(rec.getString("UserName")); bEmployee.setPassword(rec.getString("Password")); bEmployee.setTeam(rec.getString("Team")); bEmployee.setFirstname(rec.getString("FirstName")); // bEmployee.setFirstname("aaaaFirstName"); bEmployee.setLastname(rec.getString("LastName")); bEmployee.setEmail(rec.getString("Email")); bEmployee.setTelephone(rec.getString("Tel")); bEmployee.setSupervisor(rec.getBoolean("Supervisor")); bEmployee.setAdmin(rec.getBoolean("Admin")); } conn.close(); st.close(); System.out.println("passer apres ---<<>>---" + bEmployee.getEmployeeid() + "/" + bEmployee.getFirstname() + "/"); } catch (SQLException s) { System.out.println("SQL Error: " + "\n" + "s: " + s.toString() + " " + "\n" + "Error code: " + s.getErrorCode() + " " + "\n" + "sale state: " + s.getSQLState() + " " + "\n" + "message: " + s.getMessage()); // System.out.println(employeeID+"/" + "\n" + username+"/" + "\n" +password+"/"+ "\n" + team+"/"+ "\n" + firstname+"/"+ "\n" + lastname+"/"+ "\n" +email+"/"+ "\n" +telephone+"/"+ "\n" +supervisor+"/"+ "\n" +admin+"/"+ "\n" +createdBy+"/" ) ; } catch (Exception e) { System.out.println("Error: " + e.toString() + e.getMessage()); } return bEmployee; } }
Partager