package org.baswell.routes;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RoutesServlet extends HttpServlet
{
  private static RoutesEntry routesEntry = new RoutesEntry();

  @Override
  protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException
  {
    if (!routesEntry.process(servletRequest, servletResponse))
    {
      servletResponse.setStatus(404);
    }
  }
}
package org.baswell.routes;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RoutesServlet extends HttpServlet
{
  private RoutesEntry routesEntry;

  @Override
  public void init(ServletConfig config) throws ServletException
  {
    super.init(config);
    routesEntry = new RoutesEntry();
  }


  @Override
  protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException
  {
    if (!routesEntry.process(servletRequest, servletResponse))
    {
      servletResponse.sendError(404);
    }
  }
}
--- 
+++ 
@@ -1,6 +1,5 @@
 package org.baswell.routes;
 
-import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -9,22 +8,14 @@
 
 public class RoutesServlet extends HttpServlet
 {
-  private RoutesEntry routesEntry;
-
-  @Override
-  public void init(ServletConfig config) throws ServletException
-  {
-    super.init(config);
-    routesEntry = new RoutesEntry();
-  }
-
+  private static RoutesEntry routesEntry = new RoutesEntry();
 
   @Override
   protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException
   {
     if (!routesEntry.process(servletRequest, servletResponse))
     {
-      servletResponse.sendError(404);
+      servletResponse.setStatus(404);
     }
   }
 }
Make RoutesEntry static incase servlet is instianted for each request.
