ResourceServlet.java

  1. /*
  2.  * Copyright 2010-2025 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application;

  20. import java.io.IOException;

  21. import javax.servlet.ServletException;
  22. import javax.servlet.annotation.WebInitParam;
  23. import javax.servlet.annotation.WebServlet;
  24. import javax.servlet.http.HttpServletRequest;
  25. import javax.servlet.http.HttpServletResponse;

  26. import org.eclipse.jetty.servlet.DefaultServlet;
  27. /**
  28.  * The Class ResourceServlet.
  29.  */
  30. @WebServlet(urlPatterns = { "/favicon.ico", "/robots.txt", "/sitemap.xml", "*.cache.js", "*.woff", "*.ttf", "*.css",
  31. "*.gif", "/VAADIN/themes/valo/fonts/themeicons-webfont/*", "/VAADIN/themes/valo/fonts/vaadin-icons/*",
  32. "/VAADIN/widgetsets/com.hack23.cia.web.widgets.WebWidgetSet/dcharts/*", "/VAADIN/themes/cia/*",
  33. "/VAADIN/themes/valo/shared/*", "/VAADIN/themes/valo/shared/img/*" }, loadOnStartup = 1, initParams = {
  34.                 @WebInitParam(name = "gzip", value = "true"),
  35.                 @WebInitParam(name = "etags", value = "true"),
  36.                 @WebInitParam(name = "cacheControl", value = "public, max-age=31536000"),
  37.                 @WebInitParam(name = "precompressed", value = "true")
  38.         }, asyncSupported = true)
  39. public class ResourceServlet extends DefaultServlet {

  40.     /** The Constant serialVersionUID. */
  41.     private static final long serialVersionUID = 1L;

  42.     /**
  43.      * Default constructor for ResourceServlet.
  44.      */
  45.     public ResourceServlet() {
  46.         // Default constructor
  47.     }

  48.      @Override
  49.       protected void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
  50.          response.setHeader("Pragma", "cache");
  51.          super.service(request, response);
  52.       }


  53. }