summaryrefslogtreecommitdiffhomepage
path: root/test/java/url_pattern
diff options
context:
space:
mode:
Diffstat (limited to 'test/java/url_pattern')
-rw-r--r--test/java/url_pattern/app.java39
-rw-r--r--test/java/url_pattern/web.xml75
2 files changed, 114 insertions, 0 deletions
diff --git a/test/java/url_pattern/app.java b/test/java/url_pattern/app.java
new file mode 100644
index 00000000..88b071a2
--- /dev/null
+++ b/test/java/url_pattern/app.java
@@ -0,0 +1,39 @@
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class app extends HttpServlet
+{
+ private String id;
+
+ @Override
+ public void init(ServletConfig sc)
+ throws ServletException
+ {
+ id = sc.getInitParameter("id");
+ }
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ response.addHeader("X-Id", id);
+ response.addHeader("X-Request-URI", "" + request.getRequestURI());
+ response.addHeader("X-Servlet-Path", "" + request.getServletPath());
+ response.setHeader("X-Path-Info", "" + request.getPathInfo());
+
+ response.setContentType("text/plain; charset=utf-8");
+
+ PrintWriter out = response.getWriter();
+ out.println("app.doGet(): #" + this + ", " + id);
+ out.println("RequestURI: " + request.getRequestURI());
+ out.println("ServletPath: " + request.getServletPath());
+ out.println("PathInfo: " + request.getPathInfo());
+ }
+}
diff --git a/test/java/url_pattern/web.xml b/test/java/url_pattern/web.xml
new file mode 100644
index 00000000..048400a6
--- /dev/null
+++ b/test/java/url_pattern/web.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="3.0">
+
+ <servlet>
+ <servlet-name>servlet0</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>servlet0</param-value></init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>servlet1</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>servlet1</param-value></init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>servlet2</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>servlet2</param-value></init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>servlet3</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>servlet3</param-value></init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>servlet4</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>servlet4</param-value></init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>default</servlet-name>
+ <servlet-class>app</servlet-class>
+ <init-param><param-name>id</param-name><param-value>default</param-value></init-param>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>servlet0</servlet-name>
+ <url-pattern>/foo/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>servlet1</servlet-name>
+ <url-pattern>/foo/bar/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>servlet2</servlet-name>
+ <url-pattern>/baz/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>servlet3</servlet-name>
+ <url-pattern>/catalog</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>servlet4</servlet-name>
+ <url-pattern>*.bop</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+