| /* |
| * Copyright (c) 2020 Kentyou. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Kentyou - initial API and implementation |
| */ |
| package org.eclipse.sensinact.gateway.sthbnd.http.android; |
| |
| import javax.servlet.Filter; |
| import javax.servlet.FilterChain; |
| import javax.servlet.FilterConfig; |
| import javax.servlet.ServletException; |
| import javax.servlet.ServletRequest; |
| import javax.servlet.ServletResponse; |
| import javax.servlet.annotation.WebFilter; |
| import javax.servlet.http.HttpServletResponse; |
| import java.io.IOException; |
| |
| /** |
| * @author RĂ©mi Druilhe |
| */ |
| @WebFilter( urlPatterns= {"/android"}, asyncSupported=false) |
| public class IndexFilter implements Filter { |
| private final String alias; |
| |
| IndexFilter(String alias) { |
| this.alias = alias; |
| } |
| |
| public void init(FilterConfig filterConfig) throws ServletException { |
| } |
| |
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| ((HttpServletResponse) response).sendRedirect(alias + "/index.html"); |
| } |
| |
| public void destroy() { |
| } |
| } |