Skip to content

Commit dbfc8dd

Browse files
committed
Add exercise19
1 parent cca20e6 commit dbfc8dd

7 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'tomcat'
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.0'
10+
}
11+
}
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
compile 'org.glassfish.jersey.containers:jersey-container-servlet-core:2.7'
19+
compile 'org.glassfish.jersey.ext:jersey-mvc:2.7'
20+
compile 'org.glassfish.jersey.ext:jersey-mvc-jsp:2.7'
21+
22+
def tomcatVersion = '7.0.11'
23+
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
24+
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
25+
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
26+
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>
3+
<title>Say Your Name</title>
4+
</head>
5+
<body>
6+
<form action="hellos" method="POST">
7+
Name: <input type="text" name="name"><br/>
8+
<input type="submit">
9+
</form>
10+
</body>
11+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'tomcat'
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.0'
10+
}
11+
}
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
compile 'org.glassfish.jersey.containers:jersey-container-servlet-core:2.7'
19+
compile 'org.glassfish.jersey.ext:jersey-mvc:2.7'
20+
compile 'org.glassfish.jersey.ext:jersey-mvc-jsp:2.7'
21+
22+
def tomcatVersion = '7.0.11'
23+
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
24+
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
25+
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
26+
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
27+
}
28+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tw.codedata;
2+
3+
import java.util.*;
4+
5+
import javax.ws.rs.DefaultValue;
6+
import javax.ws.rs.POST;
7+
import javax.ws.rs.Path;
8+
import javax.ws.rs.FormParam;
9+
10+
import org.glassfish.jersey.server.mvc.Viewable;
11+
12+
@Path("/hellos")
13+
public class Hellos {
14+
@POST
15+
public Viewable add(@FormParam("name") String name) {
16+
Map model = new HashMap();
17+
model.put("name", name);
18+
return new Viewable("/add", model);
19+
}
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
5+
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
6+
<filter>
7+
<filter-name>jersey</filter-name>
8+
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
9+
<init-param>
10+
<param-name>jersey.config.server.provider.packages</param-name>
11+
<param-value>tw.codedata</param-value>
12+
</init-param>
13+
<init-param>
14+
<param-name>jersey.config.server.provider.classnames</param-name>
15+
<param-value>org.glassfish.jersey.server.mvc.jsp.JspMvcFeature</param-value>
16+
</init-param>
17+
<init-param>
18+
<param-name>jersey.config.server.mvc.templateBasePath.jsp</param-name>
19+
<param-value>/</param-value>
20+
</init-param>
21+
<init-param>
22+
<param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
23+
<param-value>/.*html</param-value>
24+
</init-param>
25+
</filter>
26+
<filter-mapping>
27+
<filter-name>jersey</filter-name>
28+
<url-pattern>/*</url-pattern>
29+
</filter-mapping>
30+
</web-app>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2+
<html>
3+
<head>
4+
<title>Hello, ${it.name}</title>
5+
</head>
6+
<body>
7+
Hello, ${it.name}
8+
</body>
9+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>
3+
<title>Say Your Name</title>
4+
</head>
5+
<body>
6+
<form action="hellos" method="POST">
7+
Name: <input type="text" name="name"><br/>
8+
<input type="submit">
9+
</form>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)