diff options
Diffstat (limited to 'test/java/welcome_files')
-rw-r--r-- | test/java/welcome_files/app.java | 67 | ||||
-rw-r--r-- | test/java/welcome_files/dir1/index.txt | 1 | ||||
-rw-r--r-- | test/java/welcome_files/dir2/default.jsp | 3 | ||||
-rw-r--r-- | test/java/welcome_files/dir2/index.html | 1 | ||||
-rw-r--r-- | test/java/welcome_files/dir3/index.txt | 1 | ||||
-rw-r--r-- | test/java/welcome_files/dir4/index.html | 1 | ||||
-rw-r--r-- | test/java/welcome_files/index.htm | 1 | ||||
-rw-r--r-- | test/java/welcome_files/web.xml | 27 |
8 files changed, 102 insertions, 0 deletions
diff --git a/test/java/welcome_files/app.java b/test/java/welcome_files/app.java new file mode 100644 index 00000000..ce922531 --- /dev/null +++ b/test/java/welcome_files/app.java @@ -0,0 +1,67 @@ + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +public class app extends HttpServlet +{ + @WebFilter(urlPatterns = "*.jsp") + public static class jsp_filter implements Filter + { + @Override + public void init(FilterConfig filterConfig) { } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ((HttpServletResponse) response).addHeader("X-JSP-Filter", "1"); + + chain.doFilter(request, response); + } + + @Override + public void destroy() { } + } + + @WebFilter(urlPatterns = "*.txt") + public static class txt_filter implements Filter + { + @Override + public void init(FilterConfig filterConfig) { } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ((HttpServletResponse) response).addHeader("X-TXT-Filter", "1"); + + chain.doFilter(request, response); + } + + @Override + public void destroy() { } + } + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + { + response.addHeader("X-App-Servlet", "1"); + response.setContentType("text/plain; charset=utf-8"); + + PrintWriter out = response.getWriter(); + out.println("App Servlet"); + } +} diff --git a/test/java/welcome_files/dir1/index.txt b/test/java/welcome_files/dir1/index.txt new file mode 100644 index 00000000..e7784d20 --- /dev/null +++ b/test/java/welcome_files/dir1/index.txt @@ -0,0 +1 @@ +This is index.txt. diff --git a/test/java/welcome_files/dir2/default.jsp b/test/java/welcome_files/dir2/default.jsp new file mode 100644 index 00000000..48627641 --- /dev/null +++ b/test/java/welcome_files/dir2/default.jsp @@ -0,0 +1,3 @@ +<%@ page contentType="text/html"%> +<html><body><p>You should see this on <a href="/dir2/">/dir2/</a> URL.</p></body></html> +<% response.addHeader("X-Unit-JSP", "ok"); %> diff --git a/test/java/welcome_files/dir2/index.html b/test/java/welcome_files/dir2/index.html new file mode 100644 index 00000000..5b111825 --- /dev/null +++ b/test/java/welcome_files/dir2/index.html @@ -0,0 +1 @@ +<html><body><p>You should see this on <a href="/dir2/">/dir2/</a> URL.</p></body></html> diff --git a/test/java/welcome_files/dir3/index.txt b/test/java/welcome_files/dir3/index.txt new file mode 100644 index 00000000..8a2b7dea --- /dev/null +++ b/test/java/welcome_files/dir3/index.txt @@ -0,0 +1 @@ +You should never see this. diff --git a/test/java/welcome_files/dir4/index.html b/test/java/welcome_files/dir4/index.html new file mode 100644 index 00000000..2cef75e2 --- /dev/null +++ b/test/java/welcome_files/dir4/index.html @@ -0,0 +1 @@ +<html><body><p>You should see this for <a href="/dir4/index.html">/dir4/index.html</a> or <a href="/dir4/">/dir4/</a> url.</body></html> diff --git a/test/java/welcome_files/index.htm b/test/java/welcome_files/index.htm new file mode 100644 index 00000000..97e34cf5 --- /dev/null +++ b/test/java/welcome_files/index.htm @@ -0,0 +1 @@ +<html><body><p>You should see this ONLY for <a href="/index.htm">/index.htm</a> url.</body></html> diff --git a/test/java/welcome_files/web.xml b/test/java/welcome_files/web.xml new file mode 100644 index 00000000..6bbc7c8e --- /dev/null +++ b/test/java/welcome_files/web.xml @@ -0,0 +1,27 @@ +<?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"> + + <welcome-file-list> + <welcome-file>index.txt</welcome-file> + <welcome-file>default.jsp</welcome-file> + <welcome-file>index.html</welcome-file> + </welcome-file-list> + + <servlet> + <servlet-name>app</servlet-name> + <servlet-class>app</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>/dir3/index.txt</url-pattern> + <url-pattern>/dir4/index.txt</url-pattern> + <url-pattern>/dir5/index.html</url-pattern> + </servlet-mapping> + +</web-app> + |