tp 1a
This commit is contained in:
parent
b663754fc7
commit
3d3dfe37f0
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,25 +0,0 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
45
tp1a/7.html
Normal file
45
tp1a/7.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Formulaire César</title>
|
||||
<script type="text/javascript">
|
||||
var httpRequest;
|
||||
function requeteHTTP(i, n) {
|
||||
console.log("i = " +i);
|
||||
console.log("n = " +n);
|
||||
if (i === "") return false;
|
||||
if ( (n >= 0) && (n <= 26) ) {
|
||||
httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = () => {
|
||||
accuseReception(httpRequest);
|
||||
};
|
||||
httpRequest.open('GET', "http://localhost:8080/cesar/" + n + "?val=" + i, true);
|
||||
httpRequest.setRequestHeader("Content-Type", "application/json");
|
||||
httpRequest.send();
|
||||
}
|
||||
}
|
||||
|
||||
function accuseReception(httpRequest) {
|
||||
if (httpRequest.readyState == XMLHttpRequest.DONE) {
|
||||
if (httpRequest.status == 200) {
|
||||
console.log(httpRequest.responseText);
|
||||
document.getElementById("resultat").innerHTML = httpRequest.responseText;
|
||||
} else {
|
||||
console.error('Il y a eu un problème avec la requête.');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<label for="val">Texte à chiffrer :</label>
|
||||
<input type="text" id="val" name="val" required><br />
|
||||
<label for="decal">Decallage :</label>
|
||||
<input type="text" id="decal" name="decal" required>
|
||||
<br>
|
||||
<button onclick="requeteHTTP(document.getElementById('val').value, document.getElementById('decal').value)">Envoyer</button>
|
||||
</fieldset>
|
||||
<div id="resultat"></div>
|
||||
</body>
|
||||
</html>
|
39
tp1a/8.html
Normal file
39
tp1a/8.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Formulaire César</title>
|
||||
<script type="text/javascript">
|
||||
var httpRequest;
|
||||
function requeteHTTP(i) {
|
||||
if (i === "") return false;
|
||||
httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = () => {
|
||||
accuseReception(httpRequest);
|
||||
};
|
||||
httpRequest.open('GET', "http://localhost:8080/allcesar?val=" + i, true);
|
||||
httpRequest.setRequestHeader("Content-Type", "application/json");
|
||||
httpRequest.send();
|
||||
}
|
||||
|
||||
function accuseReception(httpRequest) {
|
||||
if (httpRequest.readyState == XMLHttpRequest.DONE) {
|
||||
if (httpRequest.status == 200) {
|
||||
console.log(httpRequest.responseText);
|
||||
document.getElementById("resultat").innerHTML = httpRequest.responseText;
|
||||
} else {
|
||||
console.error('Il y a eu un problème avec la requête.');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<label for="val">Texte à chiffrer :</label>
|
||||
<input type="text" id="val" name="val" required><br />
|
||||
<br>
|
||||
<button onclick="requeteHTTP(document.getElementById('val').value)">Envoyer</button>
|
||||
</fieldset>
|
||||
<div id="resultat"></div>
|
||||
</body>
|
||||
</html>
|
39
tp1a/9.html
Normal file
39
tp1a/9.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Formulaire César</title>
|
||||
<script type="text/javascript">
|
||||
var httpRequest;
|
||||
function requeteHTTP(i) {
|
||||
if (i === "") return false;
|
||||
httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = () => {
|
||||
accuseReception(httpRequest);
|
||||
};
|
||||
httpRequest.open('POST', "http://localhost:8080/allcesar", true);
|
||||
httpRequest.setRequestHeader("Content-Type", "application/json");
|
||||
httpRequest.send(i);
|
||||
}
|
||||
|
||||
function accuseReception(httpRequest) {
|
||||
if (httpRequest.readyState == XMLHttpRequest.DONE) {
|
||||
if (httpRequest.status == 200) {
|
||||
console.log(httpRequest.responseText);
|
||||
document.getElementById("resultat").innerHTML = httpRequest.responseText;
|
||||
} else {
|
||||
console.error('Il y a eu un problème avec la requête.');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<label for="val">Texte à chiffrer :</label>
|
||||
<input type="text" id="val" name="val" required><br />
|
||||
<br>
|
||||
<button onclick="requeteHTTP(document.getElementById('val').value)">Envoyer</button>
|
||||
</fieldset>
|
||||
<div id="resultat"></div>
|
||||
</body>
|
||||
</html>
|
13
tp1a/README.md
Normal file
13
tp1a/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# TP1 - Utiliser un service REST
|
||||
|
||||
1. Nous voyons un JSON de la forme ``{"message":"Hello, Spring!"}``.
|
||||
2. Une API REST.
|
||||
3. On fait des requêtes GET. Elles sont effectuées sur le port 8080.
|
||||
4. Non, car on a pas la description de l'API.
|
||||
5. Un décallage de César est effectué au texte passé en paramètre. Pour "bonjour", avec un décallage de 5, on obtient "gtsotzw" via l'URI ``http://localhost:8080/cesar/5?val=bonjour``.
|
||||
6. Il s'agit de la valeur sur laquelle on veut appliquer le décallage de césar.
|
||||
7. Voir 7.html
|
||||
8. La méthode allcesar de notre service effectue un décallage de césar 26 fois pour nous montrer les 26 possibilités sur un texte.
|
||||
|
||||
|
||||
|
14
tp1a/index.html
Normal file
14
tp1a/index.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Formulaire César</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="http://localhost:8080/cesar/1" method="GET">
|
||||
<label for="val">Texte à chiffrer :</label>
|
||||
<input type="text" id="val" name="val" required>
|
||||
<br>
|
||||
<input type="submit" value="Chiffrer">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
BIN
tp1a/service-complete-1.jar
Normal file
BIN
tp1a/service-complete-1.jar
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user