WIP: Versuch den StaticTest zu reparieren...
[percentcodec] / examples / static / src / main / java / de / halbekunst / cachecontrol / examples / SimpleDefaultServlet.java
1 package de.halbekunst.cachecontrol.examples;
2
3 import java.io.FileInputStream;
4 import java.io.IOException;
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import org.apache.commons.io.IOUtils;
10
11 /**
12  * Möglichst simple Fake-Implementierung für die Ausführung des Testfalls
13  *
14  * @author kai
15  */
16 public class SimpleDefaultServlet extends HttpServlet {
17
18   @Override
19   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
20     String path = getServletContext().getRealPath(request.getRequestURI());
21     if (path == null) {
22       response.sendError(HttpServletResponse.SC_NOT_FOUND);
23       return;
24     }
25     IOUtils.copy(new FileInputStream(path), response.getOutputStream());
26   }
27 }