Bonjour lors de l'execution de mon application j'obtiens l'erreur suivante :
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
PWC6199: Generated servlet error:
source value 1.5 is obsolete and will be removed in a future release
PWC6199: Generated servlet error:
target value 1.5 is obsolete and will be removed in a future release
PWC6199: Generated servlet error:
To suppress warnings about obsolete options, use -Xlintptions.
PWC6199: Generated servlet error:
'catch' without 'try'
PWC6199: Generated servlet error:
'finally' without 'try'
PWC6199: Generated servlet error:
'try' without 'catch' or 'finally'
PWC6199: Generated servlet error:
reached end of file while parsing
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:129)
cela m'ai arrivé quand j'ai r'ajouté le code de rechercher dans ma jsp celui là :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <% if( request.getAttribute("listVendeur") != null ){ ArrayList<Vendeur> listVendeur = (ArrayList<Vendeur>) request.getAttribute("listVendeur"); for(Vendeur v : listVendeur ){ %> <tr> <th scope="row"><%= v.getLogin()%></th> <td><%= v.getPassword()%></td> <td><%= v.getMatricule()%></td> </tr>
du coup l'erreur viens surment de là
Pour bien comprendre voici tout le code ma page jsp :
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 <%@page import="java.util.ArrayList"%> <%@page import="model.Vendeur"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="Css/Css_creation_vendeur.css" rel="stylesheet"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <title>JSP Page</title> </head> <body> <div id="header_creation_vendeur"> <h2>Creation vendeur</h2> </div> <form method="get" action="Creation_vendeur"> <div id="div_cv1"> <div class="form-group form-inline"> <label>Matricule</label> <input type="text" name="matricule" class="form-control form-control-md" id="matricule"/> <input type="submit" class="btn btn-warning btn-lg" name="action" value="rechercher" id="rech"> </div> </div> <table class="table table-hover" id="table"> <thead> <tr class="table-active"> <th scope="col">Login</th> <th scope="col">Password</th> <th scope="col">Matricule</th> </tr> </thead> <tbody> <% if( request.getAttribute("listVendeur") != null ){ ArrayList<Vendeur> listVendeur = (ArrayList<Vendeur>) request.getAttribute("listVendeur"); for(Vendeur v : listVendeur ){ %> <tr> <th scope="row"><%= v.getLogin()%></th> <td><%= v.getPassword()%></td> <td><%= v.getMatricule()%></td> </tr> </tbody> </table> </form> <form method="post" action="Creation_vendeur"> <div id="div_cv2"> <div class="form-group form-inline"> <label>Matricule</label> <input type="text" name="matricule2" class="form-control form-control-md" id="matricule2"/> </div> <div class="form-group form-inline"> <label>Login</label> <input type="text" name="logincv" class="form-control form-control-md" id="logincv" /> </div> <div class="form-group form-inline"> <label>Mot de passe</label> <input type="password" name="password" class="form-control form-control-md" id="password" /> </div> <div class="form-group form-inline"> <label>Role</label> <div class="form-check-input"> <input type="radio" class='form-check-input' value="2" name='radio' id="radiovendeur"/> </div> <label class="form-check-label"> Vendeur </label> <div class="form-check-input"> <input type="radio" class='form-check-input' value="1" name='radio' id="radioadmin"/> </div> <label class="form-check-label"> Administrateur </label> </div> <div class="form-group form-inline"> <label>Etat</label> <div class="form-check-input"> <input type="radio" class='form-check-input' value="0" name='radio2' id="radioactif"/> </div> <label class="form-check-label"> Actif </label> <div class="form-check-input"> <input type="radio" class='form-check-input' value="1" name='radio2' id="radioinactif"/> </div> <label class="form-check-label"> Inactif </label> </div> </div> <div id="buttoncv"> <div class="form-group form-inline"> <input type="submit" class="btn btn-warning btn-lg" name="action" value="ajouter"> <input type="reset" class="btn btn-warning btn-lg" value="Effacer"> <input type="submit" class="btn btn-warning btn-lg" name="action" value="modifier"> </div> </div> </form> </body> </html>
et voici le code de ma servlet :
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
113
114
115
116
117
118
119
120
121
122
123
124 @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection c=cnx.getcnx(); PreparedStatement stmt = null; ResultSet re1 = null; Vendeur v=null; String matricule2 = request.getParameter("matricule2"); ArrayList<Vendeur> listVendeur = new ArrayList<Vendeur>(); try{ stmt=c.prepareStatement("select * from vendeurs where matricule=?"); stmt.setString(1, matricule2); re1=stmt.executeQuery(); while(re1.next()){ v=new Vendeur(re1.getString(1),re1.getString(2),re1.getString(3)); listVendeur.add((Vendeur) v); } } catch (SQLException ex) { Logger.getLogger(Creation_vendeur.class.getName()).log(Level.SEVERE, null, ex); } request.setAttribute("listVendeur", listVendeur); getServletContext().getRequestDispatcher("/WEB-INF/Creation_vendeur.jsp").forward(request, response); } /** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String matricule2=request.getParameter("matricule2"); String logincv=request.getParameter("logincv"); String password=request.getParameter("password"); String radio= request.getParameter("radio"); String radio2=request.getParameter("radio2"); Connection c=cnx.getcnx(); if(request.getParameter("action").equals("ajouter")){ try { PreparedStatement st=c.prepareStatement("insert into vendeurs values (null,?,?,?,null,null,?,null)",Statement.RETURN_GENERATED_KEYS); st.setString(1, logincv); st.setString(2, password); st.setString(3, matricule2); st.setString(4, radio2); st.executeUpdate(); int key=-1; ResultSet rs = st.getGeneratedKeys(); if (rs.next()) { key = rs.getInt(1); } System.out.print(key); PreparedStatement st1=c.prepareStatement("insert into vendeurinroles values (null,?,?)"); st1.setInt(1, key); st1.setInt(2, Integer.parseInt(radio)); int res=st1.executeUpdate(); if(res>0){ System.out.println("ajouter avec succes"); } else { System.out.println("erreur"); } } catch(Exception ex){ ex.printStackTrace(); } } else if(request.getParameter("action").equals("modifier")){ try{ PreparedStatement stm=c.prepareStatement("update vendeurs set login=? , password=? , isactive=? where matricule=?",Statement.RETURN_GENERATED_KEYS); stm.setString(1, logincv); stm.setString(2, password); stm.setString(3, radio2); stm.setString(4, matricule2); /* int keym=-1; ResultSet rs = stm.getGeneratedKeys(); if (rs.next()) { keym = rs.getInt(1); } System.out.print(keym); */ stm.executeUpdate(); PreparedStatement stm2=c.prepareStatement("update vendeurinroles set role_id=? where vendeur_id in(select id from vendeurs where matricule=?)"); stm2.setInt(1, Integer.parseInt(radio)); stm2.setString(2, matricule2); int resmodification=stm2.executeUpdate(); if(resmodification>0){ System.out.println("Modifier avec succes"); } else { System.out.println("erreur"); } } catch(Exception ex){ ex.printStackTrace(); } } getServletContext().getRequestDispatcher("/WEB-INF/Creation_vendeur.jsp").forward(request, response); }
Pour le code d'ajout et modification tout marche à merveille.
Pour le code de rechercher j'ai créé une requete et une arraylist dans ma servlet le bute est que je stoque le résultat de ma requete dans cette arraylist et apres j'utilise mon arraylist dans la page jsp pour récupéré les valeurs pour les affichez dans mon tableau.
Pour l'erreur j'ai recherché sur le net ils disent que c'est un probleme de version de jdk pourtant j'ai bien la version 8.
Aidez moi svp !!!
Partager