Skip to content

Commit 99a09fa

Browse files
authored
Add files via upload
1 parent 048b817 commit 99a09fa

9 files changed

Lines changed: 89 additions & 0 deletions

File tree

118 KB
Loading
121 KB
Loading
116 KB
Loading
119 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
3+
<display-name>jspajax</display-name>
4+
<welcome-file-list>
5+
<welcome-file>index.html</welcome-file>
6+
<welcome-file>index.htm</welcome-file>
7+
<welcome-file>index.jsp</welcome-file>
8+
<welcome-file>default.html</welcome-file>
9+
<welcome-file>default.htm</welcome-file>
10+
<welcome-file>default.jsp</welcome-file>
11+
</welcome-file-list>
12+
</web-app>

AJAX-JSP/WebContent/details.jsp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2+
pageEncoding="ISO-8859-1"%>
3+
<%
4+
String str = request.getParameter("str");
5+
System.out.println("Str="+str);
6+
7+
if(str.equals("casablanca")) {
8+
out.print("We' ll always have Paris.");
9+
}
10+
else if (str.equals("lovestory")) {
11+
out.print("Love means never have to say you're sorry.");
12+
}
13+
else if (str.equals("scarface")) {
14+
out.print("Say hello to my little friend.");
15+
}
16+
else if (str.equals("taxidriver")) {
17+
out.print("Are you talking to me?");
18+
}
19+
else if (str.equals("thedarkknight")) {
20+
out.print("Why so serious?");
21+
}
22+
else if (str.equals("thegodfather")) {
23+
out.print("I'm going to make him an offer he can't refuse.");
24+
}
25+
else if (str.equals("thesilence")) {
26+
out.print("I'm having an old friend for dinner.");
27+
}
28+
%>
181 KB
Loading

AJAX-JSP/WebContent/index.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Movie Quotes</title>
6+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
7+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
8+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
9+
<script>
10+
function fetch(str){
11+
var request = new XMLHttpRequest();
12+
request.onreadystatechange = function(){
13+
if(this.readyState == 4 && this.status == 200){
14+
var response = this.responseText;
15+
document.getElementById("stage").innerHTML=response;
16+
}
17+
};
18+
request.open("GET", "details.jsp?str="+str, true);
19+
request.send();
20+
}
21+
</script>
22+
<script>
23+
</script>
24+
25+
<style>
26+
body {padding: 10%; margin: 0; text-align: center;}
27+
h2 {color:maroon;}
28+
#stage {font-family:verdana;padding:30px;font-size:14pt;}
29+
</style>
30+
31+
</head>
32+
<body>
33+
<img src="imgs/movies.jpg" class="img-responsive" />
34+
<h2>Some Movie Quotes</h2>
35+
<hr>
36+
<button type="button" class="btn btn-warning" onclick="fetch('casablanca')">Casablanca</button>
37+
<button type="button" class="btn btn-warning" onclick="fetch('lovestory')">Love Story</button>
38+
<button type="button" class="btn btn-warning" onclick="fetch('scarface')">Scarface</button>
39+
<button type="button" class="btn btn-warning" onclick="fetch('taxidriver')">Taxi Driver</button>
40+
<button type="button" class="btn btn-warning" onclick="fetch('thedarkknight')">The Dark Knight</button>
41+
<button type="button" class="btn btn-warning" onclick="fetch('thegodfather')">The Godfather</button>
42+
<button type="button" class="btn btn-warning" onclick="fetch('thesilence')">The Silence of the Lamps</button>
43+
<button type="button" class="btn btn-default" onclick="document.getElementById('stage').innerHTML='';">Clear</button>
44+
<div id="stage"></div>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)