salut tout le monde
j'ai une page html et page jsp
la page html contient un formulaire je veux afficher message devant chaque type="text" ,par exemple si agent ne saisie pas ou oublie de saisir le nom alors un message sera afficher d'erreur devant la case
je vous montre le code
agent.html
et
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 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head><title>Messages</title></head> <body bgcolor="#FFFF66"> <form action="jagent.jsp" method="post"> <p><table border="1" cellpadding="3" cellspacing="2" width="90%" align="center"> <tr> <td bgcolor="#FF9900" width="100"><b>Nom</b></td> <td><input type="text" name="nom"></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Prénom</b></td> <td><input type="text" name="prénom"></td> </tr> </table></p> <p align="center"><input type="submit" value="Nouvel utilisateur"></p> </form> </body> </html>
jagent
je veux afficher ce message "cette information est obligatoire" devant la case nom
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 <%@page import="java.sql.*"%> <%@page import="oracle.jdbc.*"%> <%@page import="oracle.sql.*"%> <% String nom = request.getParameter("nom"); String prénom= request.getParameter("prénom"); out.println("le nom de l'agnet " + nom + " et le prénom =" + prénom); Connection conn=null; try { Connection connection = null; // Load the JDBC driver String driverName = "oracle.jdbc.driver.OracleDriver"; Class.forName(driverName); // Create a connection to the database String serverName = "10.133.0.25"; String portNumber = "1521"; String sid = "fin"; String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber +":" + sid; String username = "DEV"; String password = "MUSTAPHA"; connection = DriverManager.getConnection(url, username, password); Statement instruction = connection.createStatement(); if (nom.length()<1 ) { out.println("cette information est obligatoire " +"<BR>" ); } else { int jagent = instruction.executeUpdate("INSERT INTO agent(nom,prénom)VALUES ('"+nom+"','"+prénom+"')"); } } catch (Exception gD) { System.out.println("ERREUR1 " + gD); } %>
Partager