<html>
<body>
<java>
String message;
if ((message = request.getParameter("MESSAGE")) == null) {
out.print("No message query argument supplied.");
out.print("Please use an URL like request1.jhtml?MESSAGE=Hello");
}
else
out.print("Message is " + message);
</java>
</body> </html>
<form action="calcul.jhtml" method=post>
Quelles sont vos connaissances de HTML ?
<input type="radio" name="choice" value="1" checked>faibles
<input type="radio" name="choice" value="2">moyennes
<input type="radio" name="choice" value="3">bonnes
Indiquez votre expertise en programmation:
<input type="radio" name="choice2" value="1" checked>absente
<input type="radio" name="choice2" value="2">moyenne
// un string vide pour comparer
String emptyString = new String ("");
String AdresseString = req.getParameter("adresse");
if ( AdresseString.equals(emptyString) ) { ... geuler ...}
// Parameters come as strings
String choice = request.getParameter("choice");
String choice2 = request.getParameter("choice2");
// Integer.parseInt() translates a string to an Integer
int score = Integer.parseInt(choice) + Integer.parseInt(choice2);
out.print("<h3>Votre score est de " + score + "</h3>");
if (score < 3) {
out.print ("<p>Vous êtes un débutant</p>");
} else if (score < 5) {
out.print ("<p>Vous avez un niveau moyen</p>");
} else {
out.print ("<p>Vous êtes un expert !</p>");
}