Introducing Java Servlet Container beta.
This commit is contained in:
67
test/java/welcome_files/app.java
Normal file
67
test/java/welcome_files/app.java
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
1
test/java/welcome_files/dir1/index.txt
Normal file
1
test/java/welcome_files/dir1/index.txt
Normal file
@@ -0,0 +1 @@
|
||||
This is index.txt.
|
||||
3
test/java/welcome_files/dir2/default.jsp
Normal file
3
test/java/welcome_files/dir2/default.jsp
Normal file
@@ -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"); %>
|
||||
1
test/java/welcome_files/dir2/index.html
Normal file
1
test/java/welcome_files/dir2/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body><p>You should see this on <a href="/dir2/">/dir2/</a> URL.</p></body></html>
|
||||
1
test/java/welcome_files/dir3/index.txt
Normal file
1
test/java/welcome_files/dir3/index.txt
Normal file
@@ -0,0 +1 @@
|
||||
You should never see this.
|
||||
1
test/java/welcome_files/dir4/index.html
Normal file
1
test/java/welcome_files/dir4/index.html
Normal file
@@ -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>
|
||||
1
test/java/welcome_files/index.htm
Normal file
1
test/java/welcome_files/index.htm
Normal file
@@ -0,0 +1 @@
|
||||
<html><body><p>You should see this ONLY for <a href="/index.htm">/index.htm</a> url.</body></html>
|
||||
27
test/java/welcome_files/web.xml
Normal file
27
test/java/welcome_files/web.xml
Normal file
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user